cache.get returns default value when pickle reader encounters EOFError #177
cache.get returns default value when pickle reader encounters EOFError #177ikeikeikeike wants to merge 1 commit intograntjenks:masterfrom
Conversation
|
Seems like a cache miss then? I would expect the default value, not an IOError. |
|
Thanks, your response.
|
|
Any idea? The present situation, a EOFError is caught by the except-statement, Supposedly, I wonder it is broken in writing process while an unexpected occurred. |
|
I don’t know how it gets into a bad state here. But I do not want to break the atomic transaction guarantee. It still looks like a cache miss to me. For your project, the code can subclass Disk and use that for Cache initialization. Look in the docs for JSONDisk for an example. Without understanding more about how the cache got into this state, I’m not comfortable with the change. |
, which behaves in the same way as FileNotFoundError.
EOFError happened when a blank file is read by pickle reader. I don't know specifically what is going on why blank file is there, instead of large file. Although, EOFError is going to throw permanently.
FYO. The
io.IOBasereturns empty string instead. https://docs.python.org/3/library/exceptions.html#EOFErrorAddition: This PR is just to take it as a suggestion, thus it is closable.