'Print out the enxt trigger wake up time after completing a job
I am running Advanced Python Scheduler on a server-side daemon process that has two interval jobs configured:
scheduler = BlockingScheduler()
scheduler.add_job(live_cycle, 'interval', seconds=self.tick_size.to_timedelta.total_seconds(), start_time=start_time + self.tick_offset)
scheduler.add_job(live_positions, 'interval', seconds=self.stats_refresh_frequency.to_timedelta.total_seconds(), start_time=start_time)
scheduler.start()
I am using a BlockingScheduler and single-threaded execution mode, as my use case demands quite deterministic execution. Tasks themselves are have short lifetime, should never overlap and nothing bad happens if they are delayed a bit.
My question is about the devops part of BlockingScheduler: there can be long delays before the next scheduled wake up for a job, like weeks. To make sure that the operator of this application has better understanding when to expect more log output, I would like to print out an info level logging statement along the lines:
Scheduler is now going to sleep. Next wake up is in X days Y hours, at 2022-XX-ZZ.
What would be a good way to add this functionality to my app? Should I extend BlockingScheduler or are there any event handler I can use?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
