If there is no modified data, do not write.#54
Merged
msiemens merged 1 commit intomsiemens:masterfrom May 20, 2015
Merged
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>> ignored
The case happens when the objects has been closed and __del__ 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.
Owner
|
Thank you for the PR! Do you have an idea how this could be tested? |
Contributor
Author
|
This would reproduce it. I am not sure how to integrate into the test framework; since this is an igored exception in |
Owner
|
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. |
msiemens
added a commit
that referenced
this pull request
May 20, 2015
CachingMiddleware: Don't write if no data has been modified
Owner
|
I've now released v2.3.2 which contains your changes 😃 |
Contributor
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids an exception:
The case happens when the objects has been closed and del 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.