Skip to content

Commit 357fbcf

Browse files
committed
fix: Don't swallow caller cancellation in AsyncRepeatingTask.wait_stopped
wait_stopped awaited the worker with a bare await + except CancelledError, which conflated the worker's expected stop() cancellation with cancellation of the caller itself — a timed/cancelled stop() could swallow the cancel and return as if it completed. Use asyncio.wait({task}) (as join_handle already does): it absorbs the worker's cancellation without re-raising it, while still propagating a cancellation of the caller.
1 parent 6631fbc commit 357fbcf

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

ldclient/impl/aio/concurrency.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,7 @@ async def wait_stopped(self):
228228
the task never started or is the current task."""
229229
task = self.__task
230230
if task is not None and task is not asyncio.current_task():
231-
try:
232-
await task
233-
except asyncio.CancelledError:
234-
pass
231+
await asyncio.wait({task})
235232

236233
async def _run(self):
237234
try:

0 commit comments

Comments
 (0)