0

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.

malkoto1
  • 417
  • 8
  • 19

1 Answers1

0

I found the problem:

The problem is that subprocess.call() "calls" the notepad and waits for its completion.

What it menas in simple words is that the program will end when the Notepad opened from this script is closed.

malkoto1
  • 417
  • 8
  • 19