From 997c195ed2fe313325db6dafbafbc0856dc598d7 Mon Sep 17 00:00:00 2001 From: jimmylai Date: Mon, 22 May 2017 22:32:46 -0700 Subject: [PATCH] [3.5] call remove_done_callback in finally section (GH-1688) (cherry picked from commit 21b3e04c13212b29e8c35ffc36eed8603fde08f4) --- 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 50153f8d4bd291..26a6f1ef859f2d 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -459,7 +459,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.')