Option to not remove jobs on completion
See original GitHub issueIs your feature request related to a problem? Please describe.
Hi. In my app, I am giving users the option to run any particular job as recurring or just run it once. Regardless of job schedule, I am keeping track of all executions in a separate table. In order to do this, I have to call apscheduler.get_job
during EVENT_JOB_EXECUTED
. Unfortunately, when the job is run once, it is removed from the database before I can make that call to get details about the execution, making it impossible for me to store information about the result.
Describe the solution you’d like I would like an option for the scheduler to not remove jobs on completion of single run events. Maybe give it a status of “COMPLETE” or something. That way, it’s still clear to APScheduler that a job was run at some point, event though it won’t have to handle it anymore.
Alternatively, it might be more generally useful to pass the entire Job during the event lifecycle. This might be a lot slower for people with a bunch of jobs though.
Describe alternatives you’ve considered Because I am also storing the output of the executions, I haven’t found a way to grab the return string in any other way but through the JobExecutionEvent.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I think your use case is valid but I would look into modifying the job completion event so that it contains all the necessary information.
I agree! In the meantime, I’ve just subclassed the scheduler I’m using and added additional logic to handle single run events. Thanks for the consideration.