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

オープン 初心者向け
#2,002 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

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

  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:

def __del__(self):
    try:
        self.close()
    except Exception:
        pass
主要言語
Python
スター
10.6k
フォーク
1.5k
平均マージ
23分
マージ済み PR(30日)
1

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

abetlen/llama-cpp-python のほかの issue

abetlen/llama-cpp-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。