Function stopping a function

Sorin Schwimmer sxn02 at yahoo.com
Fri Nov 23 18:36:15 CET 2007


In my situation, there is a device with keyboard that
allows some user input. In the same time, the device
is connected to a standard PC, and there may be some
communication there.

The lengthy_function() resides and executes in the
device, and so is cancel().

Lengthy_function() is pretty linear: according to some
conditions, the user is asked for this or that. Than,
with the new conditions, lenghty_function() may need
to communicate with the PC. And now, with the updated
conditions, may ask more stuff from user.

At any time the user can press a CANCEL button, or the
PC can generate a CANCEL.

What I have now is a global variable which cancel()
will change and then, each "if" statement in
lenghty_function() will check that variable, together
with its specific condition. I was hopping that there
may be a more elegant solution.

No threads involved in my design (apart for what the
device may have to handle events like button-press and
serial communication).

Thanks everyone for your answers.

Regards,
SxN


      ____________________________________________________________________________________
Get easy, one-click access to your favorites. 
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs 



More information about the Python-list mailing list