Skip to content

Commit f51aad8

Browse files
docs: clarify threadsafety=1 thread-binding contract
PEP 249 threadsafety=1 is an upper bound ("threads may share the module"). Expand the inline comment to state the stricter invariant actually enforced: connections are bound to the thread that created them (sync) or the event loop that first used them (async). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 70e7d34 commit f51aad8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/dqlitedbapi/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@
3131

3232
# PEP 249 module-level attributes
3333
apilevel = "2.0"
34-
threadsafety = 1 # Threads may share the module, but not connections
34+
# PEP 249 value 1: threads may share the module.
35+
#
36+
# This driver is stricter than the PEP minimum: each Connection is
37+
# bound to the thread that created it. Any method call from a
38+
# different thread raises ProgrammingError. Use one Connection per
39+
# thread, or use the async API (dqlitedbapi.aio.aconnect) for a
40+
# single-thread-per-loop model.
41+
threadsafety = 1
3542
paramstyle = "qmark" # Question mark style: WHERE name=?
3643

3744
# SQLite compatibility attributes (for SQLAlchemy)

src/dqlitedbapi/aio/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131

3232
# PEP 249 module-level attributes (required by SQLAlchemy dialect initialization)
3333
apilevel = "2.0"
34-
threadsafety = 1 # Threads may share the module, but not connections
34+
# PEP 249 value 1: threads may share the module.
35+
#
36+
# The async API is further restricted: each AsyncConnection is bound
37+
# to the event loop it was first used on (see dqlitedbapi.aio.connection).
38+
# Use one AsyncConnection per loop.
39+
threadsafety = 1
3540
paramstyle = "qmark" # Question mark style: WHERE name=?
3641

3742
# SQLite compatibility attributes (for SQLAlchemy)

0 commit comments

Comments
 (0)