Python/Jython - threading.Timer()
VLP
vlprasad at yahoo.com
Thu Dec 19 21:01:37 EST 2002
Ype Kingma <ykingma at accessforall.nl> wrote in message news:<3e021ce6$0$129$e4fe514c at dreader5.news.xs4all.nl>...
> The Timer class is new in 2.2.
> This might do the trick:
>
> from threading import Thread
> import time
>
> class Timer(Thread):
> def __init__(self, interval, function, *args, **kwargs):
> Thread.__init__()
> self.interval = interval
> self.function = function
> self.args = args
> self.kwargs = kwargs
> self.start()
>
> def run(self):
> time.sleep(self.interval)
> return self.function(*self.args, **self.kwargs)
>
> I'm not sure about the args and kwargs stuff, but it works without
> arguments.
> You could probably just copy the Timer class from the python 2.2
> distribution; I don't have it ready here.
>
> Have fun,
> Ype
Thanks a lot... this works great!
Regards,
VLP
More information about the Python-list
mailing list