аватар question@mail.ru · 01.01.1970 03:00

How to implement a function that works at a certain time?

The task is to make a method that works at a certain hour.

I suppose you need to do this in the asynchronous method (so as not to interfere with the main program). There is only a thought that after some time to check from the system what time (cycle) and, if the hour is needed, then perform some function, but is there really no other way? In case it takes not an hour, but a minute.

аватар answer@mail.ru · 01.01.1970 03:00

For such purposes, the module is perfect.

An example from the documentation:

   Import  SEDULE  Import  Time  def   job  ():   Print  ( "" i'm working ... "" ) schedule.evary ( 10 ). Minutes.do (Job) schedule.evry (). Hour.do (Job) schedule.evary (). Day.at ( "" 10:30 "" ). Do (JOB) schedule.evry ( 5 ). To ( 10 ). Minutes.do (Job) schedule.evry (). monday.do (Job) schedule.evary (). Wednesday.at ( "" 13:15 "" ). Do (job) schedule.evry (). Minute.at ( "" "" ). Do (Job)   While   true :  schedule.ru_pending ()  time.sleep ( 1 )   

and in order not to interrupt the implementation of the main program, you can run the checks of the check in a separate stream or process using standard libraries and, accordingly,

Latest

Similar