This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subprocess raising "No Child Process" OSError
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: slowfood
Priority: normal Keywords:

Created on 2007-07-16 22:15 by slowfood, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
subprocess_noChildErr.py slowfood, 2007-07-16 22:15 Subprocess OSError on multiple CPU's
Messages (1)
msg32520 - (view) Author: slowfood (slowfood) Date: 2007-07-16 22:15
The program below demostrates a "No Child Process" OSError on a multi-cpu systems.

This is extracted from a large system where we
are trying to manage many sub-processes,
some of which end up having little/no real work to
do so they return very fast, here emulated by
having the sub-process be an invocation of:
  Executable="/bin/sleep 0"

Seems like some race condition, since if you make the
child process take some time (sleep 0.1) the frequency
of errors decreeses.
Error only shows up when there are more threads than 
have real CPU's by at least a factor of two, on dual core machines up NumThreads to 18 to get the failures.

Same error on both Python 2.4.3 with:
 Linux 2.6.18-gentoo-r3  Gentoo 
and Python 2.4.4 with:
 Linux 2.6.20-gentoo-r8

Any help appreciated -

= = = ===== Start code example ===========

% python subprocess_noChildErr.py
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib64/python2.4/threading.py", line 442, in __bootstrap
    self.run()
  File "testCaseA.py", line 14, in run
    subprocess.call(Executable.split())
  File "/usr/lib64/python2.4/subprocess.py", line 413, in call
    return Popen(*args, **kwargs).wait()
  File "/usr/lib64/python2.4/subprocess.py", line 1007, in wait
    pid, sts = os.waitpid(self.pid, 0)
OSError: [Errno 10] No child processes

Test finished
% cat subprocess_noChildErr.py
import subprocess, threading

# Params
Executable="/bin/sleep 0"
NumThreads = 18
NumIterations = 10

class TestClass(threading.Thread):
   def __init__(self, threadNum):
       self.threadNum = threadNum
       threading.Thread.__init__(self)
   def run(self):
       for i in range(NumIterations):
           subprocess.call(Executable.split())

def test():
   allThreads = []
   for i in range(NumThreads):
       allThreads.append(TestClass(i))
   for i in range(NumThreads):
       allThreads[i].start()
   for i in range(NumThreads):
       allThreads[i].join()
   print "Test finished"

if __name__ == '__main__':
   test()


% python -V
Python 2.4.4
% uname -a
Linux 2.6.20-gentoo-r8 #2 SMP PREEMPT Sun Jul 1 13:22:56 PDT 2007 x86_64 Dual-Core AMD Opteron(tm) Processor 2212 AuthenticAMD GNU/Linux
%
% date
Fri Jul 13 19:26:44 PDT 2007
%

= = = ===== End code example ===========


History
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45210
2007-07-16 22:15:56slowfoodcreate