Code Monkey home page Code Monkey logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 16, 2024
Hi, is there any further progress on the `close` feature?

Thanks.

Original comment by [email protected] on 18 May 2015 at 10:35

from py-leveldb.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 16, 2024
Unfortunately, no. Because of the threading issues, I felt the implementation 
would be complicated, and was a bit reluctant to pursue it.

Note that there is a very good and active fork at 
https://github.com/rjpower/py-leveldb, and a not so active (mine) at 
https://github.com/arnimarj/py-leveldb

Original comment by [email protected] on 18 May 2015 at 2:26

from py-leveldb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.