Replies: 1 comment
-
|
Thanks for the thorough write-up @essiebx; this is a well-reasoned proposal and the patterns you've identified are real. Happy to see this move forward. I've opened #396 to track it. Reference it with A few notes before you start, so the PR lands cleanly: Scope — keep it tight. Limit this to On Lock discipline. Tests are the bar for acceptance. Add coverage for both paths through each context manager:
A test that asserts the lock is free after an exception (e.g. a subsequent operation succeeds) is the important one. Out of scope for this PR: read methods that only need If that works for you, go ahead and open a PR against |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Pattern 2: Transaction wrapping (in
insert,update,delete)Each method manually coordinates the lock and transaction lifecycle, increasing code volume and
cognitive overhead.
Proposed Solution
Extract two lightweight context managers:
1. Lock + State Guard
2. Transaction + Lock
This reduces patterns like:
Benefits
with self._db.engine.begin(),with self._db.engine.connect())Precedent
The codebase already embraces this pattern:
LocalStoreandClientimplement__enter__/__exit__for lifecycle managementwith self._db.engine.begin() as conn:andwith self._db.engine.connect() as conn:extensivelyclose()explicitly"Scope
LocalStoreinsert(),update(),delete(),query(),stats()to use new patternsThoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions