I have a task in Python and i run this task for first time and i want after 60 second run the same task but only one last time.
If you want something done twice with a gap, the simplest way is just to sleep for a bit:
from time import sleep
do_task()
sleep(60)
do_task()
Note that this could not be suitable if you need precisely 60 seconds.
The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following execution of that signal’s catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.
In that case, you may want to store the time before the sleep and compare to ensure the right amount of time has passed, for example, but in most cases it doesn't need to be so precise.
Note that this pauses execution, if you want to do this with other things going on, you will need to look into threading.
Call the task directly the first time and from a timer the second time. The call to wx.CallLater
will not block, so the application remains responsive while the timer is running.
do_task()
wx.CallLater(60 * 1000, do_task)
See http://www.wxpython.org/docs/api/wx.CallLater-class.html
Timer
is also an option, see http://stackoverflow.com/questions/9999873/python-watch-long-running-process-alert-after-so-many-minutes/9999994#999999 - Niklas B. 2012-04-03 22:39