Freeze and Resume execution

Miki Tebeka miki.tebeka at zoran.com
Thu May 20 08:55:09 EDT 2004


Hello All,

I'm looking for a way to "yield" an exception.

Background: I'm writing a hardware simulator. I have an output buffer
and need to freeze when it's full and then when called again to resume
execution from the point where it stopped.

Currently all I can think of is to use a class and save the state when
throwing an exception. However this required manual book keeping of the
current state (and it is complicated).

I'd like to use generators but can't see any "nice" way of doing it.
What I'd like it to throw an exception when the buffer is full and then
next time the generator is called to continue execution as after a
"yield".

Is this possible?
Can you recommend a good way of doing this? Any state machine?

Thanks.
Bye.
--
-------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://www.cs.bgu.ac.il/~tebeka
The only difference between children and adults is the price of the toys.





More information about the Python-list mailing list