Charles-François Natali added the comment:

> No automated testing included because I'm not entirely sure how to replicate 
> this without eating up a ton of ram or doing something naughty with ulimit.

Simply use RLIMIT_NPROC, from a subprocess:
"""
$ cat /tmp/test.py
import subprocess

ps = [ ]

for i in range(1024):
    p = subprocess.Popen(['sleep', '10'])
    ps.append(p)
$ python /tmp/test.py
Traceback (most recent call last):
  File "/tmp/test.py", line 7, in ?
    p = subprocess.Popen(['sleep', '10'])
  File "/usr/lib64/python2.4/subprocess.py", line 550, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.4/subprocess.py", line 919, in _execute_child
    self.pid = os.fork()
OSError: [Errno 11] Resource temporarily unavailable
$ ulimit -u 1024
"""

Not POSIX, but supported by Linux and BSD, which should be enough.

The problem with monkey-ptching is that you don't test the real
codepath, and it may break in a future version (especially since here
it would be using a preivate API).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16327>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to