ja...@biosci.utexas.edu wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed">hi! i'm
running computationally-intensive python programs for a student
project, and i have a couple of questions.
1) how can i suspend program execution for brief periods either in
python or through IDLE;
and 2) is there a way to save state data so that if i have to quit
running a program in a student computer lab, i can write the state of
the program and all intermediate data to -- say -- a usb drive, then
read in the state data later so the program can pick up where it left
off?
thanks,
james
</div>
1a) A program can suspend itself, with a call to sleep(). While it's
sleeping, it uses very little CPU time. Similarly, if it's waiting for
console input, or in an idle loop (for a GUI app).
1b) If the program is running from an IDE, such as Komodo, then you can
set a breakpoint, and pause it, while examining values and stack
information. I'm not familiar with IDLE, so I don't know if it has
similar abilities.
2) As far as I know, there's no standardized to preserve the entire
state of any process. However, if you write a program with this in
mind, you could preserve the state of your variables with pickle.
Preserving the state of the local variables in functions currently
executing is another story, however. I don't know of any standard way
of dumping the execution frames.
When writing a GUI program, it's sometimes necessary to break up a long
computation, so that the GUI doesn't freeze. The same techniques could
be used here.
--
http://mail.python.org/mailman/listinfo/python-list