TypeError: 'NoneType' object is not callable in __del__() when exiting
還沒有人認領這個 Issue。
評估
研究方向
尋找 Llama 類別的定義,它可能位於 llama.py 之類的檔案中,或位於類似的核心模組中。找到它的 del 方法。修正方式是將 self.close() 呼叫包在 try-except 區塊中,以忽略例外。建立一個會建立模型實例並結束的簡單指令碼進行測試,確保不會出現 TypeError。
由索引模型根據 Issue 內容生成。
描述
Prerequisites
- I am running the latest code.
- I followed the README.md.
- I searched open/closed issues.
- This is a reproducible error and fix.
Expected Behavior
When the model is closed or Python exits, it should clean up resources quietly.
Current Behavior
When using Llama(...), a crash occurs on exit:
TypeError: 'NoneType' object is not callable
This happens inside __del__() when it tries to close internal objects (e.g., ExitStack or model context) that are already None.
Environment and Context
- Windows 11
- Python 3.11.3
- llama-cpp-python version: 0.3.8
- Using quantized GGUF model via
Llama(...)
Steps to Reproduce
- Load model via
Llama(model_path=..., ...) - Let script exit
- Observe destructor crash in logs
Recommended Fix
Wrap close() call in __del__() like so:
def __del__(self):
try:
self.close()
except Exception:
pass
- 主要語言
- Python
- 星號
- 10.6k
- 分支
- 1.5k
- 平均合併
- 23 分鐘
- 30 天內合併 PR
- 1
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
abetlen/llama-cpp-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 65/100
abetlen/llama-cpp-python#2352 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
abetlen/llama-cpp-python#2211 · 2 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
abetlen/llama-cpp-python#2210 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
abetlen/llama-cpp-python#2145 ·
-
難度 1/5 1 小時以內 新手友好度 75/100
abetlen/llama-cpp-python#2135 · 4 個 reaction ·
查看 abetlen/llama-cpp-python 的全部 Issue
相似的 Issue
-
documentation help wanted
難度 2/5 1-3 小時 新手友好度 90/100
-
難度 2/5 1-3 小時 新手友好度 90/100
simonw/sqlite-utils#872 ·
-
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100