abetlen / abetlen/llama-cpp-python

TypeError: 'NoneType' object is not callable in __del__() when exiting

未關閉
#2,002 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
10.6k
分支
1.4k
PR 合併指標
PR 指標待擷取

描述

# Prerequisites

- [x] I am running the latest code.
- [x] I followed the README.md.
- [x] I searched open/closed issues.
- [x] 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

1. Load model via `Llama(model_path=..., ...)`
2. Let script exit
3. Observe destructor crash in logs

# Recommended Fix

Wrap `close()` call in `__del__()` like so:

```python
def __del__(self):
try:
self.close()
except Exception:
pass

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。