Comments (3)
The implementation might be tricky. I release the Python GIL for all DB
operations, so a naive implementation might close the database in the middle of
an operation.
Not releasing it serializes DB operations, so you can add the necessary
safeguards.
One idea I had to add a close() operation, was basically to set a flag, and
then do a wait until all running DB operations are done. In the interim you
would disallow all new DB operations.
If it helps I do keep track of objects referencing the main DB object (e.g.
snapshots and iterators), which is easy to expose.
Original comment by [email protected]
on 23 May 2013 at 10:47
from py-leveldb.
If it helps, my problem is that I want to have multiple processes accessing the
same database. Obviously I need to serialize their access, but there's no way
(I can see) to get the first process to give up the db and let other processes
use it.
Original comment by [email protected]
on 23 May 2013 at 11:17
from py-leveldb.
Ok, I think I understand.
The pattern I describe is the simplest approach I've found so far. You just
need to keep track of the count all live objects and live operations. A number
which, when zero, indicates that it is safe to close the DB.
close() would then block until that number reaches zero, and then close the DB.
Perhaps a timeout would also be in order?
(I'm open to other ideas)
Original comment by [email protected]
on 23 May 2013 at 11:39
- Changed state: Accepted
from py-leveldb.
Related Issues (20)
- add setuptools support HOT 3
- Return None from LevelDB.Get rather than raising KeyError (performance) HOT 5
- build fails due to __init__.py not found HOT 3
- Allow comparator name to be specified HOT 18
- RangeIter doesn't accept None for key_from or key_to HOT 2
- RepairDB segfaults HOT 9
- RepairDB does not accept comparators HOT 1
- Support for CompactRange() HOT 1
- 求增加连接python-leveldb 32位 for windows
- Does not build due to missing snappy header HOT 2
- Build fails with latest version of snappy and pyleveldb HOT 2
- Segmentation fault ? It was py-leveldb bug ? or levelDB bug? HOT 2
- Memory leak when using WriteBatch HOT 1
- Request to update setup.py/pypi HOT 4
- Installation requires ez_setup HOT 3
- leveldb cannot be installed HOT 4
- ..
- can't iterate over the db keys & values
- Fails to build on OS X 10.9.5 with Xcode 6.1.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-leveldb.