superpollo wrote: > Diez B. Roggisch wrote: >> superpollo wrote: >>>see? the while body ran for about 7 seconds... i bet it has to do with >>>the fact that the timer does not control inner loops... any suggestion? >> >> >> Of course the inner loop isn't affected by the set event - how should it >> be, if you don't check it. >> >> if you rewrite it as this: >> >> while True: >> for repeat in range(10): >> if e.isSet(): >> break >> print time.time() >> time.sleep(.66) >> >> it should terminate earlier. > > so it seems almost impossible to allocate a certain amount of time to a > code fragment *without* somehow rewriting its logic? > > am i wrong?
No, you are right, for threads that is. You can try & trick around with the trace-functionality of python, and some ctypes-based system-thread-module-tricks that are, as mentioned before, black-magic & a spinning gatling gun pointed to your very own lower extremities. The only reliable way of terminating an asynchronous computation is to use processes, since python2.6 that's rather convenient with the multiprocessing-module. However, that imposes some limits to what you can do. Diez -- http://mail.python.org/mailman/listinfo/python-list