Skip to content

Commit

Permalink
test: make more stable by waiting for task to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Feb 16, 2024
1 parent aa4a987 commit c9365e6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/integration/memleak_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gc
import threading
import time
import weakref
from pathlib import Path
Expand Down Expand Up @@ -45,6 +46,11 @@ def _scoped_test_memleak(
shell = weakref.ref(kernel().shell)
session = weakref.ref(kernel().session)
page_session.goto("about:blank")
if context()._last_kernel_cull_task:
if not context()._last_kernel_cull_task.done():
event = threading.Event()
context()._last_kernel_cull_task.add_done_callback(lambda _: event.set())
assert event.wait()
assert context().closed_event.wait(10)
if shell():
del shell().__dict__
Expand Down

0 comments on commit c9365e6

Please sign in to comment.