Is it possible to save a running program and reload next time ?

fdu.xiaojf at gmail.com fdu.xiaojf at gmail.com
Thu Sep 21 09:25:03 EDT 2006


Dennis Lee Bieber wrote:
> On Thu, 21 Sep 2006 15:34:21 +0800, "fdu.xiaojf at gmail.com"
> <fdu.xiaojf at gmail.com> declaimed the following in comp.lang.python:
>
>   
>> Is it possible that the program can save all running data to a file when 
>> I want it to stop, and can reload the data and continue to run from 
>> where it stops when the computer is free ?
>>
>>     
> 	You'd have to write the code to save state, which means you'd have
> to be at a known resumable point... I suspect that, if you're nested
> into a recursive function, that will not be possible as you'd have to
> recreate the calling stack along with populating all know data.
>
> 	It should be pointed out that "chaos theory" sort of got its start
> from an attempt at doing something similar -- saving a massive data
> array for later reloading. It turns out the saved data didn't have the
> full resolution of the computations, so the restart from the saved data
> diverged rapidly from where the prior run had been heading. (As I
> recall, it was a weather simulation in the late 60s early 70s, and the
> data was saved in single-precision text format -- meaning round-off
> errors on output/input; these days it would be the equivalent of the
> losses inherent in doing a long computation in 80-bit IEEE, but saving
> intermediates [for reload] in 64-bit IEEE).
>
> 	The other option may not be available under most operating system...
> Namely a snapshot of the entire "core" of memory, so you can restore the
> machine /exactly/ to the state it had been at the time of the snapshot
> (this would probably affect everything on the machine -- all other
> programs, etc.)
>
>
> 	Though if someone else have more information contradicting me, I'd
> be happy to hear it... <G>
>   
Thank you all!

Can objects be saved and reloaded by "Pickle"  ?  I have tried but no
success.

One of my friends tell me that VMware can save the current state of a
virtual machine by suspending it, and can restore the identical state
later. When a virtual machine is suspended , a file with a .vmss
extension is created(about 20M), which  contains the entire state of the
virtual machine. When you resume the virtual machine, its state is
restored from the .vmss file.

So can this method be implemented with python ?

I have another idea. When python is running, it uses about 10M memory.
So can I just save a copy of the memory used by python and restore it
later ?

Regards,

xiaojf




More information about the Python-list mailing list