2

I have a python script which in turn executes other python scripts. I put this as a task on WinXP task scheduler. the thing runs - command prompt is opened, sparks are flying, magic happens... eventually the task is completed, I get a nice 'print script ended!!' and back to prompt. but Task Scheduler thinks the task is still running ! which in turn prevents it from running it again on daily basis.

so I tried making a BAT file which just calls the script:

script.py
echo pyfinished

to my surprise cannot see 'pyfinished' at the end ...

Hanan
  • 1,395
  • 4
  • 18
  • 29
  • 3
    What does `script.py` look like? – sarnold Mar 28 '11 at 09:06
  • 2
    are you using threads in your script ? – mouad Mar 28 '11 at 09:11
  • 4
    With no code, there's really not much we can do except speculate randomly. Please create the **smallest** piece of Python code that reproduces the problem and post that **small** piece of code as part of your question. – S.Lott Mar 28 '11 at 10:00
  • 1
    I take it you mean you ran the batch file manually? Between that and Task Scheduler's behavior, it sounds like your Python script isn't actually exiting. Check in Task Manager. – Tom Zych Mar 28 '11 at 10:08
  • @all the script is one of my company's nightly build scripts too huge to produce any piece of example code. So guessing is what I am actually looking for. The scripts call to many test scripts which use threads - so guessing the process didn't quit seems like a very reasonable one. – Hanan Mar 28 '11 at 12:02
  • My current workaround is to let Task Scheduler kill the process after 23 hours. – Hanan May 04 '11 at 14:16
  • 1
    @all the reason was os.system('cmd /K script.py') - the /K cause the process to never exit. – Hanan Jun 29 '11 at 15:13

2 Answers2

2

I have this problem as well. What I did to make sure the script stops is configure the task to stop after 1 hour (or however long the script(s) should take). This kills the task and thus when the task schedule comes around again, it has no problem kicking off.

As for why Task Scheduler can't detect the script is finished, I have no idea. It's royally annoying.

user1070061
  • 473
  • 2
  • 5
  • 11
0

a line with os.system('cmd /K script.py') makes the process stay alive until I manually kill it.

Hanan
  • 1,395
  • 4
  • 18
  • 29