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 ...

7
  • 3
    What does script.py look like? Commented Mar 28, 2011 at 9:06
  • 2
    are you using threads in your script ? Commented Mar 28, 2011 at 9: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. Commented Mar 28, 2011 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. Commented Mar 28, 2011 at 10:08
  • 1
    @all the reason was os.system('cmd /K script.py') - the /K cause the process to never exit. Commented Jun 29, 2011 at 15:13

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

2 Comments

Yes, the parent process will block waiting for the child process to exit. But why are you running double-scripts, anyway?
I'm maintaining it and it ain't (severely) broken

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.