[Tutor] Working with some sort of Timer

Alan Gauld alan.gauld at btinternet.com
Thu Feb 17 09:19:12 CET 2011


"Ryan Strunk" <ryan.strunk at gmail.com> wrote

> def heartbeat(self):
>   if self.round_clock_counter > self.round_clock_max:
>       #todo, call end_round
>       return
>   if global_vars.player.fatigue < 100:
>       global_vars.player.fatigue += 1
>   self.round_clock = delay(1, heartbeat)
>
> after the bell rings. At the same time, however, the code carries 
> the burden
> of being infinitely recursive without the proper checks in place.

Its not really recursive.
It passes itself as an argument to timer which will eventually call it 
again.
But that is not the same as recursion which actually makes the call 
inside
the function. So this should not encounter the usual problems with
recursive limits being reached.

'll leave others to comment on your other issues regarding the use
of Threading.timer because I have no real experience of its use.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list