Terminating a running task/Shutting down scheduler

56 views
Skip to first unread message

Albert

unread,
Dec 7, 2021, 2:07:52 PM12/7/21
to APScheduler
Hi Team, 

I'm writing a windows service which using the background scheduler with 1 executor of ProcessPool and cron trigger.

My service stop method basically shuts down the scheduler and then goes over the child processes and shut them down as well.

The service powered off correctly in any scenario(Turned off the scheduler shutdown wait flag), however if the scheduler already started the job, the job will keep running without any issues and process explorer will show me the job process even though the service is powered off.

I saw in some threads that it is not possible to kill a running job through the apscheduler api, but maybe someone here have an idea? is there a way to get the spawned task process PID from the apscheduler and kill it manually?

I thought maybe spawning my task from multiprocess.Process and the scheduler task will be the process.start.
I'll keep the PID as a class attribute and terminate upon service shutdown, not sure if it will work, but anyway I wanted a more elegant way if exists.

Thanks,
Albert
Reply all
Reply to author
Forward
0 new messages