how to set timer

Quinn Dunkan quinn at pfennig.ugcs.caltech.edu
Sat Sep 9 20:40:14 EDT 2000


On Fri, 08 Sep 2000 19:24:17 -0500, lynx <a at b.c> wrote:
>"ykchew" <ykchew at hotmail.com>, in <39b8357f.0 at news.tm.net.my>:
>
>>         i am developing a application that require to do some
>>         calculation in every 10 seconds.
>>        so, how can i set the timer in python??
>
>you probably want os.signal. make your calculation the handler for
>SIGALRM, then schedule an alarm (with os.signal.alarm()) for 10
>seconds. make sure your handler schedules a new one before it exits!
>
>alternatively, use threads maybe?

or, if you're not trying to do something else in the background:

while 1:
    time.sleep(10)
    calculation

:)



More information about the Python-list mailing list