Skip to content

Commit

Permalink
Move helper function to module level so it could be pickled
Browse files Browse the repository at this point in the history
not sure why was not failing for me locally but fails on CI
  • Loading branch information
yarikoptic committed Sep 13, 2024
1 parent 7301f1c commit 6c0bbca
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions dandi/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,25 +1085,27 @@ def test_DownloadDirectory_basic(tmp_path: Path) -> None:
assert set(glob(f"{tmp_path}*")) == {str(tmp_path)}

# test locking
def subproc(path, results):
try:
with DownloadDirectory(path, digests={}):
results.append("re-entered fine")
except Exception as exc:
results.append(str(exc))

with Manager() as manager:
results = manager.list()
with DownloadDirectory(tmp_path, digests={}) as dl:
dl.append(b"123")
p1 = Process(target=subproc, args=(tmp_path, results))
p1 = Process(target=_download_directory_subproc, args=(tmp_path, results))
p1.start()
p1.join()
assert len(results) == 1
assert results[0] == f"Could not acquire download lock for {tmp_path}"
assert tmp_path.read_bytes() == b"123"


# needs to be a top-level function for pickling
def _download_directory_subproc(path, results):
try:
with DownloadDirectory(path, digests={}):
results.append("re-entered fine")
except Exception as exc:
results.append(str(exc))


def test_DownloadDirectory_exc(
tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
Expand Down

0 comments on commit 6c0bbca

Please sign in to comment.