Following this article I have managed to do the following example code:
import subprocess
import time
from apscheduler.schedulers.background import BackgroundScheduler
class Test:
@classmethod
def test_method(cls):
subprocess.call(['notepad.exe'])
@classmethod
def test_stop(cls, scheduler):
print(scheduler.state)
scheduler.shutdown()
scheduler.remove_all_jobs()
print(scheduler.state)
scheduler = BackgroundScheduler()
scheduler.add_job(Test.test_method, 'interval', seconds=1, id='My Job')
scheduler.start()
time.sleep(10)
print("After Sleep")
Test.test_stop(scheduler)
The problem is that after the tenth try to open "Notepad" the program just stucks and does not end.
Can someone explain what is happening and why the script does not end?
P.S. If it helps, I am runnig it on Windows.