Commit 261ba5d
committed
fix: Replace per-call Lock creation with shared lock in SQLiteSession
The lock pattern 'with self._lock if self._is_memory_db else threading.Lock()'
creates a new Lock object for each operation when using file-based databases,
providing no thread safety for concurrent access.
This fix uses the shared self._lock for both memory and file databases,
ensuring proper synchronization for concurrent operations.
Changes:
- get_items() (line 123)
- add_items() (line 177)
- pop_item() (line 218)
- clear_session() (line 255)
Testing:
- Existing test test_sqlite_session_concurrent_access passes
- Manual verification shows proper lock reuse
- No breaking changes to API or behavior1 parent d1abf43 commit 261ba5d
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
0 commit comments