-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove or reduce some test sleeps (#2771)
- Make some test code more pythonic (e.g., generators, list comprehension) - Remove a number of unnecessary sleep calls (or vastly reduce wait time) - Teach some tests to `assert` - Remove more `print()`s Co-authored-by: Ben Clifford <benc@hawaga.org.uk>
- Loading branch information
1 parent
3306deb
commit 6b81796
Showing
7 changed files
with
93 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
import parsl | ||
import threading | ||
import time | ||
|
||
import pytest | ||
|
||
import parsl | ||
from parsl.app.app import python_app | ||
from parsl.tests.configs.local_threads import fresh_config as local_config # noqa | ||
|
||
|
||
@python_app | ||
def slow_double(x): | ||
import time | ||
time.sleep(0.1) | ||
def slow_double(x, may_continue: threading.Event): | ||
may_continue.wait() | ||
return x * 2 | ||
|
||
|
||
@pytest.mark.local | ||
def test_garbage_collect(): | ||
""" Launches an app with a dependency and waits till it's done and asserts that | ||
the internal refs were wiped | ||
""" | ||
x = slow_double(slow_double(10)) | ||
evt = threading.Event() | ||
x = slow_double(10, evt) | ||
x = slow_double(x, evt) | ||
|
||
if x.done() is False: | ||
assert parsl.dfk().tasks[x.tid]['app_fu'] == x, "Tasks table should have app_fu ref before done" | ||
assert parsl.dfk().tasks[x.tid]['app_fu'] == x, "Tasks table should have app_fu ref before done" | ||
|
||
x.result() | ||
evt.set() | ||
assert x.result() == 10 * 4 | ||
if parsl.dfk().checkpoint_mode is not None: | ||
# We explicit call checkpoint if checkpoint_mode is enabled covering | ||
# cases like manual/periodic where checkpointing may be deferred. | ||
parsl.dfk().checkpoint() | ||
|
||
time.sleep(0.2) # Give enough time for task wipes to work | ||
time.sleep(0.01) # Give enough time for task wipes to work | ||
assert x.tid not in parsl.dfk().tasks, "Task record should be wiped after task completion" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.