-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
File gets truncated upon unpickling #657
Comments
This issue was problematic for me even with the file that contained the session data. if I did something like x = 1
y = 2
with open("foo.pckl", "wb") as file:
dill.dump_session(file) and then with open("foo.pckl", "rb") as file:
dill.load_session(file) in another interpreter session/notebook I would see it start to load and then the pickle file go to zero bytes and a The way I got around this was to never instantiate a file object but rather pass the path object or path string to |
This could probably be solved by unpickling files open for write in "write append" mode. Seems like a more logical/rational/expected/intuitive behavior. |
Agreed, or to be extra safe open them in a read only mode and allow the caller to re-open in a write mode if needed. It isn't intuitive to me that a file object should be opened at all when un-pickled if it was closed prior to pickling. |
It seems that whenever a file is open for writing in the session, the (already closed) file object
f
gets unpickled in such a way that re-opens the file in writing mode, effectively truncating the file to zero length.Is this expected behavior?
The text was updated successfully, but these errors were encountered: