Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tasks): cancel all the pending tasks as we exit own loop #1430

Merged
merged 1 commit into from Jul 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()