Open GoogleCodeExporter opened 9 years ago
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 arnim...@gmail.com
on 23 May 2013 at 10:47
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 m...@whoosh.ca
on 23 May 2013 at 11:17
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 arnim...@gmail.com
on 23 May 2013 at 11:39
Original issue reported on code.google.com by
m...@whoosh.ca
on 23 May 2013 at 9:20