Sorin Schwimmer wrote: > I am thinking on something in the following form: > > <code> > import time > import thread > > delay=True > > def fn() > global delay > time.sleep(<your_amount_of_time_in_seconds>) > delay=False > > thread.start_new_thread(fn,()) > > while delay: > <statement 1> > <statement 2> > ...
if the loop calls out to python functions at least occasionally, you can eliminate the flag by abusing the interpreter's stack check mechanism: import time, thread, sys def alarm(): time.sleep(1.234) sys.setrecursionlimit(1) thread.start_new_thread(alarm, ()) def do_some_work(): pass t0 = time.time() try: while 1: do_some_work() except RuntimeError: pass print time.time() - t0 </F> -- http://mail.python.org/mailman/listinfo/python-list