Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > subprocess + python-daemon - bug/problem?

Reply
Thread Tools

subprocess + python-daemon - bug/problem?

 
 
Andy Clegg
Guest
Posts: n/a
 
      07-09-2009
Hi all,

I'm trying to daemonize a python program, and occasionally have it run
subprocesses, however I'm running into a nasty error, as follows:

"File "/users/rsg/ancl/devcocast/devcocast-svn/scripts/DaemonSpawnTes
t.py", line 5, in <module>
subprocess.Popen('echo 1').wait()
File "/usr/lib64/python2.5/subprocess.py", line 594, in __init__
errread, errwrite)
File "/usr/lib64/python2.5/subprocess.py", line 1089, in _execute_ch
ild
os.waitpid(self.pid, 0)
OSError: [Errno 10] No child processes"

The minimal testcase showing this problem is as follows:

"import daemon
import subprocess

daemon.DaemonContext(stderr = open("fakeConsole.txt","w+")).open()
subprocess.Popen('echo 1').wait()"

So there is no threading going on (I've found some bugs relating to
subprocess and threading). I'm using Fedora 10, Python 2.5.2, and
python-daemon 1.4.6 from here http://pypi.python.org/pypi/python-daemon/
..

If anyone can shed some light on the situation, I'd be extremely
grateful!

Yours,

Andy
 
Reply With Quote
 
 
 
 
Andy Clegg
Guest
Posts: n/a
 
      07-09-2009
My apologies, the python code should have been:

"import daemon
import subprocess

daemon.DaemonContext(stderr = open("fakeConsole.txt","w+")).open()
subprocess.Popen(['echo','1']).wait()"

However the error remains the same.

Yours,

Andy

On Jul 9, 10:26*am, Andy Clegg <(E-Mail Removed)> wrote:
> Hi all,
>
> I'm trying to daemonize a python program, and occasionally have it run
> subprocesses, however I'm running into a nasty error, as follows:
>
> "File "/users/rsg/ancl/devcocast/devcocast-svn/scripts/DaemonSpawnTes
> t.py", line 5, in <module>
> * * subprocess.Popen('echo 1').wait()
> * File "/usr/lib64/python2.5/subprocess.py", line 594, in __init__
> * * errread, errwrite)
> * File "/usr/lib64/python2.5/subprocess.py", line 1089, in _execute_ch
> ild
> * * os.waitpid(self.pid, 0)
> OSError: [Errno 10] No child processes"
>
> The minimal testcase showing this problem is as follows:
>
> "import daemon
> import subprocess
>
> daemon.DaemonContext(stderr = open("fakeConsole.txt","w+")).open()
> subprocess.Popen('echo 1').wait()"
>
> So there is no threading going on (I've found some bugs relating to
> subprocess and threading). I'm using Fedora 10, Python 2.5.2, and
> python-daemon 1.4.6 from herehttp://pypi.python.org/pypi/python-daemon/
> .
>
> If anyone can shed some light on the situation, I'd be extremely
> grateful!
>
> Yours,
>
> Andy


 
Reply With Quote
 
 
 
 
Sewar
Guest
Posts: n/a
 
      09-06-2009
I got the same bug.

Traceback (most recent call last):
File "./script1.py", line 30, in <module>
call(["python", "script2.py", "arg1"], stdout=sys.stdout, stderr=STDOUT)
File "/usr/lib/python2.6/subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.6/subprocess.py", line 1123, in wait
pid, sts = os.waitpid(self.pid, 0)
OSError: [Errno 10] No child processes

 
Reply With Quote
 
Sewar
Guest
Posts: n/a
 
      09-08-2009
I looked at other daemon libraries and snippets, it's clearly the bug is in
subprocess not python-daemon.
Then I found Python bug #1731717 which discusses it.

I wish my project was opensource so I can post more specific test cases.

#1731717 http://bugs.python.org/issue1731717

Thanks

 
Reply With Quote
 
Joel Martin
Guest
Posts: n/a
 
      09-16-2009
On Sep 8, 5:19 pm, Ben Finney <(E-Mail Removed)> wrote:
> Sewar <(E-Mail Removed)> writes:
> > I looked at other daemon libraries and snippets, it's clearly the bug is in
> > subprocess not python-daemon.
> > Then I found Python bug #1731717 which discusses it.


I'm running python-2.6.2 which supposedly has the fix for #1731717.
However I still still the problem with subprocess after daemonizing.
I've narrowed it down to just the setting of the SIGCLD signal.

You can reproduce the problem thus (in 2.4.6, 2.5.4 and 2.6.2):

import subprocess, signal
signal.signal(signal.SIGCLD, signal.SIG_IGN)
subprocess.Popen(['echo','foo']).wait()


This patch allows python-daemon to work with subprocess:

--- daemon.py (revision 146)
+++ daemon.py (working copy)
@@ -140,8 +140,6 @@
actually defined in the ``signal`` module will appear in
the
default map:

- * ``signal.SIGCLD``: ``None``
-
* ``signal.SIGTTIN``: ``None``

* ``signal.SIGTTOU``: ``None``
@@ -730,7 +728,6 @@

"""
name_map = {
- 'SIGCLD': None,
'SIGTSTP': None,
'SIGTTIN': None,
'SIGTTOU': None,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to import subprocess into my 'subprocess.py' file hiral Python 2 05-05-2010 12:56 PM
Process Runtime.exec causes subprocess hang. Nishi Bhonsle Java 2 11-30-2009 06:10 AM
[Subprocess/Windows] subprocess module under Windows 98 Andreas Jung Python 2 11-02-2005 05:41 PM
Running a subprocess on a "leash" Greg Kuperberg Python 1 10-08-2003 12:18 AM
Linux / how to check if subprocess is still alive Sigfried Manner C Programming 7 09-01-2003 05:59 PM



Advertisments