Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/test_soft_lease.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def flaky(path: str, *args: object, **kwargs: object) -> object:

mocker.patch(f"filelock._lease.{target}", side_effect=flaky)
seen: list[LeaseCompromise] = []
lease = _lease(marker, on_compromise=seen.append)
# A long lease keeps a slow runner's two failed ticks inside the window; the deadline has its own test above.
lease = _lease(marker, lease_duration=30, on_compromise=seen.append)
with lease:
time.sleep(_HEARTBEAT * 6) # several ticks: the first two fail, the rest recover
assert seen == []
Expand Down
6 changes: 3 additions & 3 deletions tests/test_strict_soft_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ def test_strict_soft_reaper_does_not_retry_sharing_error(tmp_path: Path, mocker:
side_effect=PermissionError(EACCES, "sharing violation"),
)

started = time.perf_counter()
sleep = mocker.patch("filelock._strict.time.sleep")

assert StrictSoftFileLock(lock_path).claims == ()
elapsed = time.perf_counter() - started
reaper_unlinks = [call.args[0] for call in unlink.call_args_list].count(private_path)
assert (reaper_unlinks, elapsed < 0.1, private_path.exists()) == (1, True, True)
assert (reaper_unlinks, sleep.call_count, private_path.exists()) == (1, 0, True)


@pytest.mark.parametrize("record", ["claim", "sentinel"])
Expand Down
Loading