1

I'm using subprocess.Popen to invoke the console application. The console application itself calling another child process to perform download operation. The parent process exits once its invoke the child process.

I'm able to get the output of the child process while running the script manually in command prompt.

But the subprocess.Popen getting hanged while running the script in system environment( post commit hook). The subprocess not getting exit.

 p1 = subprocess.Popen([Application,arg1, arg2, arg3], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
 Down_out = p1[0]
 Down_Err = p1[1]

Thanks in advance

3
  • What does this have to do with svn? Commented Dec 11, 2013 at 7:49
  • The python script invoked from post commit hook when the commit happened in my svn repository Commented Dec 11, 2013 at 8:35
  • shell=True and list arguments is almost always a mistake. Either drop shell=True (and leave the list argument alone) or convert the list argument into a string (a shell command as it would appear in a console). Commented Dec 11, 2013 at 15:44

1 Answer 1

0

It's hard to say from the info you gave, but it may be that arguments is a string with multiple arguments when they should be split into multiple elements in the list. The behavior of the program you are executing will not be what you expect if you combine all arguments into one string.

eg:

>>> from subprocess import Popen
>>> Popen(['touch', '/tmp/testing /tmp/foo']).communicate()
touch: cannot touch ‘/tmp/testing /tmp/foo’: No such file or directory
(None, None)
>>> Popen(['touch', '/tmp/testing', '/tmp/foo']).communicate()
(None, None)

In the first one, '/tmp/testing /tmp/foo' is one string.

In the second, it's two separate elements in the list. That ran as expected.

I am guessing that yours is hanging because of invalid arguments.

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

1 Comment

Could you provide the exact arguments you are passing, instead of Application, arg1, arg2, etc? Also, what you see when you run that manually?

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.