-
-
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
Reloading a session into the same module keeps the previous session #498
Comments
Thank you for reporting, @svartkanin. This is a complicated issue and, at the same time I'm explaining this to you, I'm reasoning with myself before we make any irreversible changes. If you want to add to the discussion with ideas or questions, you are more than welcome. Some historyFirst things first, if you read carefully dill's documentation about session saving, it was created and implemented—this is important— for users to be able to save an interactive session and restore it later (in the same interpreter instance or not). Note that the documentation doesn't mention, except in the description of the parameter The issueYour odd results came from an actual bug mixed with a usage that was not foreseen, that is: restoring the state of a dumped module in a different one (and one that have a different name, and that is not importable, etc.). In this regard, if you could tell what kind of problem you wanted to solve and how you were trying to do it when this came up, it would help us in making a couple of decisions. Namespace hellPython is a extremely dynamical language and, because of this, simple things like finding out if a class belongs to a module must be done at runtime. To deal with it, both Python and dill rely on some assumptions about a module's attributes, like
Should
|
Yes it seemed that I'm attempting something that is probably not the right way of doing things :)
and then analyze the Python objects after the execution, so NOT the stdout but the actual objects of the code that was run.
When the async execution is completed I attempt to read the resulting session back in and start analyzing the objects. |
Thank you again for complementing your report. The usage you are attempting is actually interesting: I can envision someone having to compare multiple versions of an object saved in different sessions by loading them to modules created at runtime. Maybe this should indeed be allowed if the target module is not in About what you are trying to do, there's a serious risk with the I don't know if your code editor is an exercise/toy project or a serious one, but the best thing you could do to isolate the user code (but still be able to inspect it) is to use something like an IPython kernel in a subprocess to execute the program and then pass commands for it to inspect the results. The kernel would return things always as text, for example, the names of the objects in |
I'm generating 2 session dumps with
and
Then loading them back into a module sequentially
I get the following output
Before the second session file is read, it clearly shows that the mod variable has no a nor b set. But then when reading in the test2.session file it suddenly sets both a and b. But only b was actually dumped into that file.
Is this an expected behavior?
I'd have expected that after the test2.session was loaded, only the b variable to be present
The text was updated successfully, but these errors were encountered: