Adding a close() method
See original GitHub issueThis a request that came up many times on the old pyrocksdb repo, but was never implemented. The reasoning seemed off to me. Without a close()
method, there really is no way to guarantee a lock is released as Python’s garbage collection can’t fully be relied on for this.
If you’re consistently recreating databases from scratch (as I am in my use-case), this really complicates things. Any chance such a method can be added?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Python File close() Method
Python automatically closes a file when the reference object of a file is reassigned to another file. It is a good practice to...
Read more >Reader close() method in Java with Examples
The close() method of Reader Class in Java is used to close the stream and release the resources that were busy in the...
Read more >Python File close() Method
The close() method closes an open file. You should always close your files, in some cases, due to buffering, changes made to a...
Read more >JavaScript Window close method
JavaScript provides an in-built function named close() to close the browser window that is opened by using window.open() method. Unlike the window.open() ...
Read more >Understanding python close method
Python automatically closes a file when the reference object of a file is reassigned to another file. It is a good practice to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d say this is a pretty important issue for anybody who require graceful shutdown of processes. Relying on del is a horrible practice that should be avoided if possible, and IMHO if necessary even warrants a backward incompatible change.
Doing
del(self._db)
may work for that specific application, but in general you’d have to carefully del() any other references to the object as well, and who knows what happens if there are circular references.NOTE: Using a weakref callback you could possibly set a flag to ensure the database was closed (well, implicitly by side effect of being garbage collected, trying to be an optimist here:) pseudocode:
I think this is a pretty serious issue that needs to be resolved. Hopefully I, or someone else get some time to look into it.
closed due to fix by #40