From: Ɓukasz Langa Date: Tue, 23 May 2017 07:36:18 +0000 (-0700) Subject: [3.5] call remove_done_callback in finally section (GH-1688) (#1758) X-Git-Tag: v3.5.4rc1~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=219ed80637102127786d67464822a9ec5878aaa7;p=python [3.5] call remove_done_callback in finally section (GH-1688) (#1758) (cherry picked from commit 21b3e04c13212b29e8c35ffc36eed8603fde08f4) --- diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 50153f8d4b..26a6f1ef85 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -459,7 +459,8 @@ class BaseEventLoop(events.AbstractEventLoop): # 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.')