- Notifications
You must be signed in to change notification settings - Fork590
If there is no modified data, do not write.#54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This avoids an exception: Exception ValueError: 'I/O operation on closed file' in <bound method CachingMiddleware.__del__ of <tinydb.middlewares.CachingMiddleware object at 0x7f9c96610a90>> ignoredThe case happens when the objects has been closed and __del__ is invoked. Since the semantics guaranteesno writes after close, avoid storage.write when there are no changes in flush seems to be a reasonable fix.
msiemens commentedMay 18, 2015
Thank you for the PR! Do you have an idea how this could be tested? |
rainwoodman commentedMay 18, 2015
This would reproduce it. I am not sure how to integrate into the test framework; since this is an igored exception in |
msiemens commentedMay 20, 2015
Hmmm... The ignored exception is raised when garbage collecting the database object while the file handle has already been closed. It appears to me that on garbage collection the file handle is collected (and closed) first, followed by the storage/middleware. But this of course depends on the Python implementation and maybe even version¹, so I'll merge this PR without an accompanying test. ¹ I've tried to reliably force garbage collection of the database object, but haven't succeeded so far. |
CachingMiddleware: Don't write if no data has been modified
msiemens commentedMay 20, 2015
I've now released v2.3.2 which contains your changes 😃 |
rainwoodman commentedMay 20, 2015
Thanks! |
This avoids an exception:
The case happens when the objects has been closed anddel is invoked. Since the semantics guarantees
no writes after close, avoid storage.write when there are no changes in flush seems to be a reasonable fix.