do something in time interval

Petr Jakes petr.jakes.tpc at
Mon Oct 6 20:07:54 CEST 2008

I have infinitive loop running script and I would like to check
something periodically after 5 seconds (minutes, hours...) time period
(I do not mean time.sleep(5) ). Till now, I have following script, but
I think there must be something more elegant.

eventFlag = False
while 1:
    seconds = time.time()
    if not int(seconds % (5)):
        if eventFlag:
            print "5 seconds, hurray"
            eventFlag = False
        eventFlag = True

Best regards

Petr Jakes

More information about the Python-list mailing list