do "some action" once a minute
Diez B. Roggisch
deets at nospam.web.de
Tue May 9 06:42:43 EDT 2006
Petr Jakes wrote:
> Thanks for your comment. It is mainly English issue (I am not native
> English speaker).
>
> OK, to be more specific, I would like to run the code, when the value
> of seconds in the timestamp become say "00".
> The whole code will run in the infinitive loop and other actions will
> be executed as well, so it can not "sleep" for 60 seconds :).
The you have to go for a thread, as otherwise you'd have to create all sorts
of checks in your program to check for the current date. That therad then
could wait like this:
import time
def seconds():
return time.localtime()[5]
def wait_for_seconds(secs=0):
while seconds() != secs:
time.sleep(.5)
def foo():
# initial wait
wait_for_seconds()
do_something()
while True:
time.sleep(50)
wait_for_seconds
do_something()
Diez
More information about the Python-list
mailing list