Skip to content

Commit

Permalink
cherry-pick(#1430): fix(tasks): cancel all the pending tasks as we ex…
Browse files Browse the repository at this point in the history
…it own loop (#1431)

fix(tasks): cancel all the pending tasks as we exit own loop (#1430)
  • Loading branch information
rwoll committed Jul 13, 2022
1 parent 024444e commit 162afd7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions playwright/sync_api/_context_manager.py
Expand Up @@ -98,5 +98,8 @@ def __exit__(self, *args: Any) -> None:
if self._watcher:
self._watcher.close()
if self._own_loop:
tasks = asyncio.all_tasks(self._loop)
for t in [t for t in tasks if not (t.done() or t.cancelled())]:
t.cancel()
self._loop.run_until_complete(self._loop.shutdown_asyncgens())
self._loop.close()

0 comments on commit 162afd7

Please sign in to comment.