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.

Title: subprocess raising "No Child Process" OSError
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
Status: closed Resolution: duplicate
Dependencies: Superseder: race condition in subprocess module
View: 1731717
Assigned To: Nosy List: abo, georg.brandl, slowfood
Priority: normal Keywords:

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

File name Uploaded Description Edit slowfood, 2007-07-14 03:06 Subprocess OSError on multiple CPU's
Messages (5)
msg32505 - (view) Author: slowfood (slowfood) Date: 2007-07-14 03:06
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
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib64/python2.4/", line 442, in __bootstrap
  File "", line 14, in run
  File "/usr/lib64/python2.4/", line 413, in call
    return Popen(*args, **kwargs).wait()
  File "/usr/lib64/python2.4/", line 1007, in wait
    pid, sts = os.waitpid(, 0)
OSError: [Errno 10] No child processes

Test finished
% cat
import subprocess, threading

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

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

def test():
   allThreads = []
   for i in range(NumThreads):
   for i in range(NumThreads):
   for i in range(NumThreads):
   print "Test finished"

if __name__ == '__main__':

% 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 ===========

msg32506 - (view) Author: Donovan Baarda (abo) * Date: 2007-08-03 19:37
Bugs 1754642 and 1753891 both look like duplicates of bug 1731717 to me. I suggest marking them both as dups of 1731717 because that one has info on the race-condition that causes this and discussions on how to fix it.
msg32507 - (view) Author: slowfood (slowfood) Date: 2007-08-03 20:01
I agree with abo that this looks to be a dup of 1731717, will try to mark it as such.
msg32508 - (view) Author: slowfood (slowfood) Date: 2007-08-03 20:07
Managed to mark it as a duplicate, but not able to tie it to 1731717.
Sorry -
msg32509 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-08-04 07:25
Closing too. Tying bugs is not supported by SF.
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45197
2010-03-04 22:49:01floxsetsuperseder: race condition in subprocess module
2007-07-14 03:06:15slowfoodcreate