using timers to force an execution time

superpollo user at example.net
Thu Jul 16 07:04:08 EDT 2009


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?

bye



More information about the Python-list mailing list