Skip to content

πŸ› fix(async): back off contended strict soft lock retries - #928

Merged
gaborbernat merged 7 commits into
tox-dev:mainfrom
feiiiiii5:fix/async-poll-delay
Nov 17, 2026
Merged

gaborbernat merged 7 commits into
tox-dev:mainfrom
feiiiiii5:fix/async-poll-delay

Conversation

@feiiiiii5

@feiiiiii5 feiiiiii5 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Processes contending for an AsyncStrictSoftFileLock retried on a fixed cadence, while the same contention on a StrictSoftFileLock waits a random delay between poll_interval and a window that starts at twice poll_interval and doubles each attempt, up to a fixed 0.05 second cap. With a poll_interval below that cap, async waiters kept retrying in step, each one publishing and rescanning its claim files at the same moment as the others. Async and sync strict locks now back off the same way under contention; locks left on the default poll_interval see no change.

The async wait loop now takes each retry's delay from the lock's backoff policy, as the sync loop already did, counting failed attempts from the start of each acquire. Only the strict soft locks define a backoff, so every other lock type gets its poll_interval back unchanged, and each delay is still clamped to the remaining timeout.

The polling how-to now says that strict locks, sync or async, widen their wait under contention instead of retrying at a fixed interval.

Replace the spy on the private _poll_delay hook with a test that checks
the delays a contended AsyncStrictSoftFileLock sleeps, which fails when
the backoff is dropped. Reword the changelog entry around that user
visible change: only a poll_interval below the 0.05 s cap jitters.
@gaborbernat gaborbernat changed the title πŸ› fix(async): invoke _poll_delay during contended polling πŸ› fix(async): back off contended strict soft lock retries Nov 16, 2026
The polling how-to said every lock retries at regular intervals, which
no longer holds for strict locks in either form. Say when they widen
their wait and why.

Move the async backoff test next to the other strict lock tests, whose
module already requires hard links, so it needs no marker or coverage
pragma of its own.
A one second timeout clamps the last delay on a slow Windows runner, so
the test now waits up to 30 seconds; cancel_check still stops it after
five draws. Also define the attempt counter next to its loop and word
the how-to backoff bound precisely.
@gaborbernat
gaborbernat merged commit 0e15ec8 into tox-dev:main Nov 17, 2026
33 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants