Skip to content

Commit c1964e9

Browse files
gescheitmiss-islington
authored andcommitted
bpo-36613: call remove_done_callback if exception (GH-12800)
Call remove_done_callback() in finally block. https://bugs.python.org/issue36613
1 parent 4461d70 commit c1964e9

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
@@ -495,10 +495,11 @@ def _on_completion(f):
495495
finally:
496496
if timeout_handle is not None:
497497
timeout_handle.cancel()
498+
for f in fs:
499+
f.remove_done_callback(_on_completion)
498500

499501
done, pending = set(), set()
500502
for f in fs:
501-
f.remove_done_callback(_on_completion)
502503
if f.done():
503504
done.add(f)
504505
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)