Closed ianfiske closed 9 years ago
Hi, I wrote someting about closing already here: https://github.com/stephan-hof/pyrocksdb/issues/10
As you can see the C++ has no explicit 'close' method, the close happens automatically on when the destruction of the instance is called. The same is true for python.
Does it help, or do you think there is a need for a explicit 'close' in python ?
Thanks for the response. I apologize for not noticing issue #10 already. I am fine to rely on object destruction to close the connection. I wrote a wrapper class that implements __enter__(self)
and __exit__(self)
so that I can use the connection within a with
context. The __exit__
method just deletes the db connection and everything works fine. (see https://gist.github.com/ianfiske/9bfcd388dcd592d976e4).
So, no -- you don't need to create a close method. Thanks!
Does it help, or do you think there is a need for a explicit 'close' in python ?
I think an explicit close would be fantastic. For instance in some unit tests I have found that I need to either re-use the same database for all tests or create databases with unique filenames, because otherwise I'm stuck trying to deallocate and garbage collect the instance every test run.
For what it's worth, the python leveldb bindings have an explicit close().
Hi, thanks for the awesome API to rocksdb.
I don't see a close() method for the rocksdb.DB class. I wind up being unable to manage the opening/closing of the connection and frequently fight with locked connections:
Is there a proper way to handle closing the database connection? Or do we need to implement the close method from the C++ driver? I would offer, but have a bit of a learning curve on the Cython front.
Thanks!