]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36613: call remove_done_callback if exception (GH-12800)
authorgescheit <gescheit12@gmail.com>
Fri, 3 May 2019 15:18:02 +0000 (18:18 +0300)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 3 May 2019 15:18:02 +0000 (08:18 -0700)
Call remove_done_callback() in finally block.

https://bugs.python.org/issue36613

Lib/asyncio/tasks.py
Misc/NEWS.d/next/Library/2019-04-12-13-52-15.bpo-36613.hqT1qn.rst [new file with mode: 0644]

index d8508376d92a48ffeee43e0d291e8485817aa386..007a459857d2081af706a2bed3115e76ca5fdd7a 100644 (file)
@@ -495,10 +495,11 @@ async def _wait(fs, timeout, return_when, loop):
     finally:
         if timeout_handle is not None:
             timeout_handle.cancel()
+        for f in fs:
+            f.remove_done_callback(_on_completion)
 
     done, pending = set(), set()
     for f in fs:
-        f.remove_done_callback(_on_completion)
         if f.done():
             done.add(f)
         else:
diff --git a/Misc/NEWS.d/next/Library/2019-04-12-13-52-15.bpo-36613.hqT1qn.rst b/Misc/NEWS.d/next/Library/2019-04-12-13-52-15.bpo-36613.hqT1qn.rst
new file mode 100644 (file)
index 0000000..8828dcc
--- /dev/null
@@ -0,0 +1 @@
+Fix :mod:`asyncio` wait() not removing callback if exception
\ No newline at end of file