3 Antworten
+ 1
The infinite loop in the try block is the blocking operation and is not part of the scheduled job, hence it is the expected behaviour of the code to keep running until an exception is occurred which can be triggered using `Ctrl+C`. So the `BackgroundScheduler` is still running in the background but your main thread is blocking. APScheduler is meant to run jobs inside the python application but not to achieve OS level scheduling. It uses threads and threads will be terminated as soon as their parent process terminates. So simply you cannot achieve the expected behaviour just using the python and APScheduler, you still need to keep running the parent process in the background to keep running the APScheduler jobs. To run the python application process in the background on linux systems you can simply use ampersand after your command, for instance: $ start &
2nd Jan 2024, 11:39 PM
Meetesh
Meetesh - avatar
0
Meetesh Thank you so much for your reply. When i run "start &" it's starting process in the background but my whole virtual machine freezes and i need to restart. Between i need platform independent solution is their any way to achieve it please help.
3rd Jan 2024, 12:13 AM
Adesh Thombare
Adesh Thombare - avatar
0
Adesh Thombare The vm should not freeze just by starting the process in background, check your resources consumption, this might be the low RAM issue. And if you want to keep running the scheduler when you close the shell, you can execute the program as a service. You can run the services on linux and windows both.
4th Jan 2024, 8:46 AM
Meetesh
Meetesh - avatar