I would like to use APScheduler to handle task scheduling and queues.
I am currently using the very basic APScheduler settings: BackgroundScheduler()
I know how to start the scheduler and set some cron on interval trigger job.
But I can't figure out how to handle a proper queue.
Here is my code:
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
def test():
print("Hello World !")
def start_job():
scheduler.add_job(
test
)
start_job() # first task
start_job() # second task
start_job() # third task
scheduler.start()
This code kind of works but I need my tasks to run one after one and not all at the same time.
I've tried using the max_instances
attribute but it doesn't change anything.
I've also tried to add an id
to my job and then only the first task is started but not the left ones giving these warning:
Execution of job "test (trigger: date[2021-01-12 17:55:48 UTC], next run at: 2021-01-12 17:55:48 UTC)" skipped: maximum number of running instances reached (1)
How am I supposed to start the left tasks ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…