[Tutor] help: threading + cron in python?
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Fri May 13 09:21:05 CEST 2005
Ok, there is an easy way :)
You can write something like :
from datetime import datetime
import time
def run_at( t, fct, fct_args = (), fct_words = {}):
now = datetime.today()
delta = (t-now).minutes
time.sleep(delta)
fct(*fct_args, **fct_kwords)
Now you can just launch this function in a new thread :)
It will wait the wanted time and launch the function at that moment !
Pierre
Aaron a écrit :
> Lets say you have a threaded program. Is there any way to make it so
> that an operation occurs at a certain time every hour (eg) like the cron
> daemon?
>
> I'm afraid I don't really understanding threading enought to make this
> work..
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
Pierre Barbier de Reuille
INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France
tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68
More information about the Tutor
mailing list