bpo-32610: Fix asyncio.all_tasks() to return only pending tasks. (GH-7174)
(cherry picked from commit 416c1ebd9896b394790dcb4f9f035b1a44ebe9ff)
Co-authored-by: Yury Selivanov <yury@magic.io>
diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py
index bb54b72..5fbab03 100644
--- a/Lib/asyncio/runners.py
+++ b/Lib/asyncio/runners.py
@@ -51,8 +51,7 @@
def _cancel_all_tasks(loop):
- to_cancel = [task for task in tasks.all_tasks(loop)
- if not task.done()]
+ to_cancel = tasks.all_tasks(loop)
if not to_cancel:
return