Skip to content

Commit 769ac7e

Browse files
bpo-36613: call remove_done_callback if exception (GH-12800)
Call remove_done_callback() in finally block. https://bugs.python.org/issue36613 (cherry picked from commit c1964e9) Co-authored-by: gescheit <[email protected]>
1 parent 128e226 commit 769ac7e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/asyncio/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,11 @@ def _on_completion(f):
457457
finally:
458458
if timeout_handle is not None:
459459
timeout_handle.cancel()
460+
for f in fs:
461+
f.remove_done_callback(_on_completion)
460462

461463
done, pending = set(), set()
462464
for f in fs:
463-
f.remove_done_callback(_on_completion)
464465
if f.done():
465466
done.add(f)
466467
else:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :mod:`asyncio` wait() not removing callback if exception

0 commit comments

Comments
 (0)