From e5ec05601331ae55748364851db5aec5aa370474 Mon Sep 17 00:00:00 2001 From: jimmylai Date: Sat, 20 May 2017 18:40:24 -0700 Subject: [PATCH] call remove_done_callback in finally section --- Lib/asyncio/base_events.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 3ff511be44a67e..33b8f4887c6a64 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -458,7 +458,8 @@ def run_until_complete(self, future): # local task. future.exception() raise - future.remove_done_callback(_run_until_complete_cb) + finally: + future.remove_done_callback(_run_until_complete_cb) if not future.done(): raise RuntimeError('Event loop stopped before Future completed.')