@@ -44,6 +44,8 @@ async def gather(self, context: Contexts):
4444
4545
4646def publish_exc_event (event : ExceptionEvent ):
47+ if isinstance (event .origin , ExceptionEvent ) or isinstance (event .exception , _ExitException ): # pragma: no cover
48+ return
4749 scopes = [sp for sp in _scopes .values () if sp .available ]
4850 subs = [slot for sp in scopes for slot in sp .subscribers if slot .publisher_id != "$backend" ]
4951 return add_task (dispatch (event , slots = subs ))
@@ -91,8 +93,6 @@ async def dispatch(event: Any, scope: str | Scope | None = None, slots: Iterable
9193 if isinstance (result , BaseException ):
9294 if isinstance (result , _ExitException ) and result .args [1 ]: # pragma: no cover
9395 return
94- if isinstance (event , ExceptionEvent ): # pragma: no cover
95- return
9696 publish_exc_event (ExceptionEvent (event , subs [_i ], result ))
9797 if isinstance (result , AsyncGeneratorType ): # pragma: no cover
9898 async for res in result :
@@ -143,8 +143,6 @@ async def serial(event: Any, scope: str | Scope | None = None, slots: Iterable[S
143143 if isinstance (result , BaseException ): # pragma: no cover
144144 if isinstance (result , _ExitException ):
145145 return result .args [0 ]
146- if isinstance (event , ExceptionEvent ):
147- return
148146 publish_exc_event (ExceptionEvent (event , subscriber , result ))
149147 elif isinstance (result , AsyncGeneratorType ): # pragma: no cover
150148 async for res in result :
@@ -163,7 +161,8 @@ async def broadcast(event: Any, scope: str | Scope | None = None, slots: Iterabl
163161 grouped , context_map = await compute (event , scope , slots , inherit_ctx )
164162 for key , subs in grouped .items ():
165163 contexts = context_map [key [1 ]]
166- async for subscriber , result in (serial_exec_concurrent (subs , contexts ) if concurrent else serial_exec (subs , contexts )):
164+ gene = serial_exec_concurrent (subs , contexts ) if concurrent else serial_exec (subs , contexts )
165+ async for subscriber , result in gene :
167166 if result is None or result is STOP :
168167 continue
169168 if result is BLOCK :
@@ -174,8 +173,6 @@ async def broadcast(event: Any, scope: str | Scope | None = None, slots: Iterabl
174173 if result .args [1 ]:
175174 return
176175 continue
177- if isinstance (event , ExceptionEvent ):
178- return
179176 publish_exc_event (ExceptionEvent (event , subscriber , result ))
180177 elif isinstance (result , AsyncGeneratorType ):
181178 async for res in result :
0 commit comments