timer problem
flupke
flupke at nonexistingdomain.com
Thu Aug 19 09:35:25 EDT 2004
Diez B. Roggisch wrote:
> You assume that Timer is looping - it isn't. So make your command start a
> Timer itself, like this:
>
> def command():
> print "called"
> t = threading.Timer(2, command )
> t.start()
>
> Or use a Thread, with an endless loop in the run()-method that sleeps for
> two secdonds. That spares you the overhead of thread-creation.
>
> Regards,
>
> Diez
This method (calling the Timer again) indeed works but to effectively
cancel the thread then, i need to make the thread t a class object and
i need to define the command function as a real function as opposed to
an anonymous function (what i tried to do).
Then it might be a better sollution to indeed create my own Timer class.
Benedict
More information about the Python-list
mailing list