Repository navigation
Serialize overlapping once calls across threads - #406
Merged
dgilland merged 2 commits intoNov 1, 2026
Merged
Conversation
Guard callback execution and cached state with a reentrant lock. Preserve exception retries, recursive calls, and pickling. AI-assisted: prepared and validated with OpenAI Codex.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #402.
Two overlapping calls can both enter a
once()callback before either setscalled, producing different results and repeating side effects. Serialize callback execution and cache access with a reentrant lock. Exceptions still allow a later retry, and same-thread recursion retains its existing behavior. Exclude the process-local lock from pickle state and recreate it when restoring the wrapper.The regression holds the first callback open while a second thread calls the wrapper. It fails against develop (
6d33598) and passes with the fix. Additional controls cover exception retries, a cachedNone, recursive calls, and pickling before and after the first call.Validation on Windows / Python 3.12:
pytest src/pydash tests --ignore=tests/pytest_mypy_testing --cov=pydash -q: 3,084 passed, 100% coverage.mypy src/pydash tests tasks.py --no-error-summary: passed.An additional run including the optional
pytest_mypy_testingdirectory produced 335 reveal-type expectation failures with the installed mypy. An isolated, unchanged worktree at6d33598produces the identical 335 failing node IDs. The normaltasks.pytest command excludes that optional directory; no test expectations were changed to mask these failures.AI assistance: this patch, tests and description were prepared and validated with OpenAI Codex. No human-review attestation is implied.