From d25877dd9b7a09d5f9552d9d185a86dc6497bc2f Mon Sep 17 00:00:00 2001 From: Nick Hill Date: Wed, 17 Jul 2024 22:24:43 -0700 Subject: [PATCH] [BugFix] Avoid secondary error in ShmRingBuffer destructor (#6530) --- vllm/distributed/device_communicators/shm_broadcast.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vllm/distributed/device_communicators/shm_broadcast.py b/vllm/distributed/device_communicators/shm_broadcast.py index 151b08c1b996c..bfea106bc027d 100644 --- a/vllm/distributed/device_communicators/shm_broadcast.py +++ b/vllm/distributed/device_communicators/shm_broadcast.py @@ -119,9 +119,10 @@ def __reduce__(self): ) def __del__(self): - self.shared_memory.close() - if self.is_creator: - self.shared_memory.unlink() + if hasattr(self, "shared_memory"): + self.shared_memory.close() + if self.is_creator: + self.shared_memory.unlink() @contextmanager def get_data(self, current_idx: int): @@ -428,7 +429,6 @@ def enqueue(self, obj): def dequeue(self): if self._is_local_reader: - overflow = False with self.acquire_read() as buf: overflow = buf[0] == 1 if not overflow: