Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect APScheduler's running jobs?

Tags:

apscheduler

I have some recurring jobs run frequently or last for a while. It seems that Scheduler().get_jobs() will only return the list of scheduled jobs that are not currently running, so I cannot determine if a job with certain id do not exists or is actually running.

How may I test if a job is running or not in this situation?

(I set up those jobs not the usual way, (because I need them to run in a random interval, not fixed interval), they are jobs that execute only once, but will add a job with the same id by the end of their execution, and they will stop doing so when reaching a certain threshold.)

like image 933
kkzxak47 Avatar asked Mar 13 '15 04:03

kkzxak47


People also ask

What are the advantages of apscheduler?

One of the main advantages of APScheduler is it can be used across different platforms or act as a replacement to the cron daemon or Windows Task Scheduler. Besides, it’s also in active development at the time of this writing. Interval-based execution (runs jobs on even intervals, with optional start/end times)

What is advanced Python scheduler (apscheduler)?

Advanced Python Scheduler (APScheduler) is a Python library that lets you schedule your Python code to be executed later, either just once or periodically. You can add new jobs or remove old ones on the fly as you please. If you store your jobs in a database, they will also survive scheduler restarts and maintain their state.

How to find the history of a job that has run?

SELECT job_name, session_id, running_instance, elapsed_time, cpu_used FROM dba_scheduler_running_jobs; Also one can use the following view to find the history details of job that has run.

What happens to my jobs when the scheduler restarts?

You can add new jobs or remove old ones on the fly as you please. If you store your jobs in a database, they will also survive scheduler restarts and maintain their state. When the scheduler is restarted, it will then run all the jobs it should have run while it was offline.


1 Answers

APScheduler does not filter the list of jobs for get_jobs() in any way. If you need random scheduling, why not implement that in a custom trigger instead of constantly readding the job?

like image 53
Alex Grönholm Avatar answered Oct 22 '22 10:10

Alex Grönholm