Skip to content

Commit

Permalink
Ignore done tasks (#3500)
Browse files Browse the repository at this point in the history
* Fix #3497: Ignore done tasks when cancels pending activities on web.run_app finalization.
  • Loading branch information
asvetlov authored Jan 8, 2019
1 parent 67bc3c2 commit 4e99e81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/3497.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore done tasks when cancels pending activities on ``web.run_app`` finalization.
9 changes: 7 additions & 2 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@
from typing_extensions import ContextManager


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


if PY_37:
all_tasks = getattr(asyncio, 'all_tasks') # use the trick to cheat mypy
all_tasks = getattr(asyncio, 'all_tasks') # noqa


_T = TypeVar('_T')
Expand Down

0 comments on commit 4e99e81

Please sign in to comment.