Reputation: 47
I have an APScheduler application running in the background and wanted to be able to interrupt certain jobs after they started. I want to do this to have more control over the processes and to prevent them from affecting other jobs.
I looked up for solutions using APScheduler itself, but what I want seems to be more like interrupting a function that is already running.
Is there a way to do this while not turning off my program? I don't want to delete the job or to stop the application as a whole, just to stop the process at specific and unpredictable situations.
Upvotes: 0
Views: 255
Reputation: 5911
On APScheduler 3, the only way to do this is to set a globally accessible variable or a property thereof to some value that is then explicitly checked by the target function. So your code will have to support the notion of being interrupted. On APScheduler 4 (not released yet, as of this writing), there is going to be better cancellation support, so coroutine-based jobs can be externally cancelled without explicitly supporting this. Regular functions still need to have explicit checks but there will now be a built-in mechanism for that.
Upvotes: 1