From 61e134dc5d3109a81368e2ab72e888611ce92fec Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 15 Dec 2021 08:19:56 -0500 Subject: [PATCH] Wake up consumers on end of channel as well --- tractor/trionics/_broadcast.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tractor/trionics/_broadcast.py b/tractor/trionics/_broadcast.py index 3a2e1e4..88198c6 100644 --- a/tractor/trionics/_broadcast.py +++ b/tractor/trionics/_broadcast.py @@ -222,7 +222,10 @@ class BroadcastReceiver(ReceiveChannel): event.set() return value - except trio.Cancelled: + except ( + trio.Cancelled, + trio.EndOfChannel, + ): # handle cancelled specially otherwise sibling # consumers will be awoken with a sequence of -1 # state.recv_ready = trio.Cancelled @@ -274,11 +277,12 @@ class BroadcastReceiver(ReceiveChannel): async def subscribe( self, ) -> AsyncIterator[BroadcastReceiver]: - '''Subscribe for values from this broadcast receiver. + ''' + Subscribe for values from this broadcast receiver. Returns a new ``BroadCastReceiver`` which is registered for and - pulls data from a clone of the original ``trio.abc.ReceiveChannel`` - provided at creation. + pulls data from a clone of the original + ``trio.abc.ReceiveChannel`` provided at creation. ''' if self._closed: