Compare commits

...

1 Commits

Author SHA1 Message Date
Alex Cheema
faac462d9a fix: unblock MpReceiver.close() to prevent pytest hang on shutdown
MpReceiver.close() only set the closed flag and closed the buffer pipe,
but did not unblock a thread stuck on queue.get() in receive_async().
This caused abandoned threads (from abandon_on_cancel=True) to keep the
Python process alive indefinitely after all tests passed, leading to
6-hour CI timeouts on aarch64-darwin.

Send an _MpEndOfStream sentinel before closing the buffer, mirroring
what MpSender.close() already does, so the blocked get() returns and
the thread can exit cleanly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 10:10:42 -08:00

View File

@@ -204,6 +204,10 @@ class MpReceiver[T]:
def close(self) -> None:
if not self._state.closed.is_set():
self._state.closed.set()
try: # noqa: SIM105
self._state.buffer.put_nowait(_MpEndOfStream())
except Exception:
pass
self._state.buffer.close()
# == unique to Mp channels ==