Add number of trials to diskutils test
@@ -19,13 +19,19 @@ from distributed.utils import mp_context
from distributed.utils_test import captured_logger, slow
-def assert_directory_contents(dir_path, expected):
+def assert_directory_contents(dir_path, expected, trials=2):
expected = [os.path.join(dir_path, p) for p in expected]
+ for i in range(trials):
actual = [
os.path.join(dir_path, p)
for p in os.listdir(dir_path)
if p not in ("global.lock", "purge.lock")
]
+ if sorted(actual) == sorted(expected):
+ break
+ else:
+ sleep(0.5)
+ else:
assert sorted(actual) == sorted(expected)
@@ -82,10 +88,10 @@ def test_two_workspaces_in_same_directory(tmpdir):
del ws
del b
gc.collect()
- assert_contents(["aa", "aa.dirlock"])
+ assert_contents(["aa", "aa.dirlock"], trials=5)
del a
gc.collect()
- assert_contents([])
+ assert_contents([], trials=5)
def test_workspace_process_crash(tmpdir):
