Skip to content

Commit 22e9723

Browse files
authored
[3.5] Ignore done tasks (#3500) (#3503)
* Fix #3497: Ignore done tasks when cancels pending activities on web.run_app finalization. (cherry picked from commit 4e99e81) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
1 parent 396ec1f commit 22e9723

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGES/3497.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ignore done tasks when cancels pending activities on ``web.run_app`` finalization.

aiohttp/helpers.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,15 @@
6363
from typing_extensions import ContextManager
6464

6565

66-
all_tasks = asyncio.Task.all_tasks
66+
def all_tasks(
67+
loop: Optional[asyncio.AbstractEventLoop] = None
68+
) -> Set['asyncio.Task[Any]']:
69+
tasks = list(asyncio.Task.all_tasks(loop)) # type: ignore
70+
return {t for t in tasks if not t.done()}
71+
6772

6873
if PY_37:
69-
all_tasks = getattr(asyncio, 'all_tasks') # use the trick to cheat mypy
74+
all_tasks = getattr(asyncio, 'all_tasks') # noqa
7075

7176

7277
_T = TypeVar('_T')

0 commit comments

Comments
 (0)