apscheduler cannot delete job

A very strange problem is the
reason why the job cannot be deleted: the job I generated with BackgroundScheduler is stored in MySQL. Later, when I use BlockingScheduler to remove it, there is no response, and the task is running! But when using BlockingScheduler to add the same job, it reports an error that there is a job with the same id in the database.

Result: This is weird. Why can't the jobs added by BackgroundScheduler be deleted by BlockingScheduler! why?why? It seems that we still delve into the source code to explore the reason!

Just tested and found that: it turns out that BlockingScheduler will not execute the following method after its start! It doesn't work if you execute the scheduler's remove_all_jobs operation before start.

——-Separation line————- I
read an article written by others: https://www.cnblogs.com/quijote/p/4385774.html , which pointed out that
BlockingScheduler: main_loop runs in the main thread of the current process , so the current thread will be blocked after calling the start function. The scheduled wake-up of the scheduler is completed through a threading.Event condition variable object.
BackgroundScheduler: Basically the same as BlockingScheduler, except that main_loop is placed in a separate thread, so the main thread will not block after calling start

In this way, I understand that the main function of blockingScheduler is to provide scheduler, so that it can read the job implementation in the database and be scheduled! But it is not suitable to use scheduler to remove related operations with job.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325815259&siteId=291194637