Skip to content

Commit 162afd7

Browse files
authored
cherry-pick(#1430): fix(tasks): cancel all the pending tasks as we exit own loop (#1431)
fix(tasks): cancel all the pending tasks as we exit own loop (#1430)
1 parent 024444e commit 162afd7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: playwright/sync_api/_context_manager.py

+3
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,8 @@ def __exit__(self, *args: Any) -> None:
9898
if self._watcher:
9999
self._watcher.close()
100100
if self._own_loop:
101+
tasks = asyncio.all_tasks(self._loop)
102+
for t in [t for t in tasks if not (t.done() or t.cancelled())]:
103+
t.cancel()
101104
self._loop.run_until_complete(self._loop.shutdown_asyncgens())
102105
self._loop.close()

0 commit comments

Comments
 (0)