Repository navigation
🐛 fix(rw): dispatch signals while SQLite waits - #1105
Merged
Merged
Conversation
Return to Python during a contended SQLite acquisition. Reserve the writer slot before retaining locks across retries so an existing writer can finish and later readers stay behind a pending writer. Fixes tox-dev#1027
PyPy can leave an executescript statement open when a Python signal handler raises during sqlite3_step. Its connection tracks statements from execute and finalizes them on close, releasing a pending writer even after a signal.
gaborbernat
force-pushed
the
fix/rw-signal-busy-wait
branch
from
November 21, 2026 03:18
4e0fd90 to
986291d
Compare
gaborbernat
marked this pull request as ready for review
November 21, 2026 04:20
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.
A single-threaded process waiting for a
ReadWriteLockcan run its Python signal handlers while another process still holds the database. A shutdown handler that raises stops the acquisition and releases the waiting connection. Previously the handler could wait until SQLite acquired the lock or the caller's timeout expired (#1027).The waiter asks SQLite to wait up to 100 ms at a time and charges elapsed time against the acquisition timeout. A single-threaded synchronous writer that needs another attempt keeps its pending lock on the same connection. Existing readers can finish, and later readers wait behind the writer. A multithreaded process on a system with fork support still releases its connection between attempts so another thread can fork.
Fixes #1027.