do something in time interval

Leon Zhang safecom at gmail.com
Mon Oct 6 14:30:06 EDT 2008


Petr,

I am not an expert, but why not to use time.sleep(5)?
If you are using wxPython, you may also try wx.Timer, in which you could set
its interval.

Good luck!
Leon

On Tue, Oct 7, 2008 at 2:07 AM, Petr Jakes <petr.jakes.tpc at gmail.com> wrote:

> 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:
>    time.sleep(0.01)
>    seconds = time.time()
>    if not int(seconds % (5)):
>        if eventFlag:
>            print "5 seconds, hurray"
>            eventFlag = False
>    else:
>        eventFlag = True
>
> Best regards
>
> Petr Jakes
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081007/8bdedf4b/attachment.html>


More information about the Python-list mailing list