close database

90 views
Skip to first unread message

pierre

unread,
Apr 18, 2012, 2:59:56 PM4/18/12
to py-le...@googlegroups.com
I'm looking for closing leveldb database, is there a way with py-leveldb

in leveldb :

Closing A Database

When you are done with a database, just delete the database object. Example:

  ... open the db as described above ...
  ... do something with db ...
  delete db;

Árni Már Jónsson

unread,
Apr 18, 2012, 3:40:35 PM4/18/12
to py-le...@googlegroups.com
Hi,

Right now the database is closed as soon as the LevelDB object is garbage collected. In CPython this seems to happen as soon as the reference count drops to zero. Iterators maintain a reference to the LevelDB object, which is removed as soon as they are garbage collected.

I did consider adding such a method, but decided not to do it for now. You´d need to check for each operation whether the database had been previously closed, and make that check thread-safe, and without a race condition.

If you´re interested please write a feature request, and I´ll see if I can make this happen.

Regards, Árni Már
Reply all
Reply to author
Forward
0 new messages