mirror of
https://github.com/NVIDIA/TensorRT-LLM.git
synced 2026-02-16 15:55:08 +08:00
[TRTLLM-10030][chore] use weakref in atexit handler (#11476)
Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
This commit is contained in:
parent
ca499d600d
commit
0ee757e03a
@ -4,6 +4,7 @@ import multiprocessing
|
||||
import platform
|
||||
import signal
|
||||
import traceback
|
||||
import weakref
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Mapping
|
||||
from pathlib import Path
|
||||
@ -88,7 +89,10 @@ class GenerationExecutor(ABC):
|
||||
self.kv_events_queues = IterationResultQueue()
|
||||
self.stats_queues = IterationResultQueue()
|
||||
|
||||
atexit.register(self.shutdown)
|
||||
atexit.register(
|
||||
lambda ref, finalizer=type(self).shutdown: finalizer(obj)
|
||||
if (obj := ref()) is not None else None,
|
||||
weakref.ref(self))
|
||||
|
||||
# This is used to capture the exceptions from the threads.
|
||||
self._error_queue = Queue()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user