From e4868ded54aff412bae6f635148ece97e2406dd4 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Thu, 10 Apr 2025 11:27:52 -0300 Subject: [PATCH] Tweaks to make cancellation happen correctly on ringbuf receiver & fix test log msg --- tests/test_ringbuf.py | 2 +- tractor/ipc/_ringbuf/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_ringbuf.py b/tests/test_ringbuf.py index 8f549b7c..2befeafc 100644 --- a/tests/test_ringbuf.py +++ b/tests/test_ringbuf.py @@ -92,7 +92,7 @@ async def child_write_shm( await sender.send(msg) if rng.msgs_generated % rng.recommended_log_interval == 0: - print(f'wrote {rng.total_msgs} msgs') + print(f'wrote {rng.msgs_generated} msgs') print('writer exit') return rng.hexdigest diff --git a/tractor/ipc/_ringbuf/__init__.py b/tractor/ipc/_ringbuf/__init__.py index 2b2b549e..2c74b88e 100644 --- a/tractor/ipc/_ringbuf/__init__.py +++ b/tractor/ipc/_ringbuf/__init__.py @@ -533,7 +533,7 @@ class RingBufferReceiveChannel(trio.abc.ReceiveChannel[bytes]): self._write_ptr += delta # yield lock and re-enter - except EFDReadCancelled: + except (EFDReadCancelled, trio.Cancelled): # while waiting for new data `self._write_event` was closed try: # if eof was signaled receive no wait will not raise @@ -654,7 +654,7 @@ async def attach_to_ringbuf_receiver( Launches `receiver._eof_monitor_task` in a `trio.Nursery`. ''' async with ( - trio.open_nursery() as n, + trio.open_nursery(strict_exception_groups=False) as n, RingBufferReceiveChannel( token, cleanup=cleanup