delay a task until certain time

后端 未结 8 2088
梦谈多话
梦谈多话 2021-01-11 11:59

What I want to do in a python script is sleep a number of seconds until the required time is reached. IE: if runAt setting is 15:20 and current time is 10:20, how can I wor

8条回答
  •  无人及你
    2021-01-11 12:17

    Using both arrow and pause:

    maintenance = arrow.now()
    EndAt = maintenance.replace(hour = 17, minute = 6, second = 0)
    print(maintenance,': Maintenance in progress. Pausing until :',EndAt)
    pause.until(EndAt.naive)
    

提交回复
热议问题