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

user1553605
  • 1,333
  • 5
  • 24
  • 42
  • What does this have to do with `svn`? – Steve P. Dec 11 '13 at 07:49
  • The python script invoked from post commit hook when the commit happened in my svn repository – user1553605 Dec 11 '13 at 08: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). – jfs Dec 11 '13 at 15:44

1 Answers1

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.

johannestaas
  • 1,175
  • 1
  • 9
  • 15
  • Could you provide the exact arguments you are passing, instead of Application, arg1, arg2, etc? Also, what you see when you run that manually? – johannestaas Dec 12 '13 at 07:30