mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
G5: F07 — await in-flight async callbacks before stop() returns
Why: EventDispatcher._process_events() calls task_done() on the queue immediately after spawning async callback tasks. await queue.join() in stop() therefore returns as soon as all items are marked done, even if their async callbacks are still executing. Any caller that does "await dispatcher.stop(); cleanup()" could race with still-running callbacks. Fix: after queue.join(), gather all tracked background tasks before cancelling the dispatch loop. Refs: Forensics report finding F07
This commit is contained in:
parent
26141d0353
commit
d4581a8e13
1 changed files with 4 additions and 0 deletions
|
|
@ -236,6 +236,10 @@ class EventDispatcher:
|
|||
self.running = False
|
||||
if self._task:
|
||||
await self.queue.join()
|
||||
# Wait for any in-flight async callbacks to complete before
|
||||
# tearing down (F07: task_done fires before callbacks finish).
|
||||
if self._background_tasks:
|
||||
await asyncio.gather(*self._background_tasks, return_exceptions=True)
|
||||
self._task.cancel()
|
||||
try:
|
||||
await self._task
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue