-
Notifications
You must be signed in to change notification settings - Fork 409
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not swallow PicklingError #1359
Changes from 6 commits
6bfd045
e7de461
151a21e
2bfb3a7
6ade8e6
0bcd263
f62202b
bd826a5
fc1fcb4
f605518
e4d1c2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||||||||||||||||
"""Storage providers backends for Memory caching.""" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
from pickle import PicklingError | ||||||||||||||||||||||||
import re | ||||||||||||||||||||||||
import os | ||||||||||||||||||||||||
import os.path | ||||||||||||||||||||||||
|
@@ -185,12 +186,24 @@ def dump_item(self, path, item, verbose=1): | |||||||||||||||||||||||
|
||||||||||||||||||||||||
def write_func(to_write, dest_filename): | ||||||||||||||||||||||||
with self._open_item(dest_filename, "wb") as f: | ||||||||||||||||||||||||
numpy_pickle.dump(to_write, f, | ||||||||||||||||||||||||
compress=self.compress) | ||||||||||||||||||||||||
try: | ||||||||||||||||||||||||
numpy_pickle.dump(to_write, f, compress=self.compress) | ||||||||||||||||||||||||
except PicklingError as e: | ||||||||||||||||||||||||
warnings.warn( | ||||||||||||||||||||||||
'Unable to cache to disk: ' | ||||||||||||||||||||||||
'failed to pickle output. ' | ||||||||||||||||||||||||
'In future versions of joblib ' | ||||||||||||||||||||||||
'this will raise an exception.' | ||||||||||||||||||||||||
'Exception: %s.' % e, | ||||||||||||||||||||||||
FutureWarning | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
self._concurrency_safe_write(item, filename, write_func) | ||||||||||||||||||||||||
except: # noqa: E722 | ||||||||||||||||||||||||
" Race condition in the creation of the directory " | ||||||||||||||||||||||||
except Exception as e: # noqa: E722 | ||||||||||||||||||||||||
warnings.warn( | ||||||||||||||||||||||||
'Unable to cache to disk. ' | ||||||||||||||||||||||||
'Possibly a race condition in the creation of the directory. ' | ||||||||||||||||||||||||
'Exception: %s' % e) | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we are changing a bit this, I would be in favor of sanitizing this, by putting a Small nitpick on style.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So following the conversation with @ogrisel , I would not do a deprecation warning but just a warning for the error. |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def clear_item(self, path): | ||||||||||||||||||||||||
"""Clear the item at the path, given as a list of strings.""" | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to avoid the old formating synthax in the new code base, so please use:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, could you please rewrap the string to better use the available <80 char limit of PEP8?
Some people complain than 80 is not enough, others seem reluctant to use more than 60 apparently ;) 80 is a good middle ground.