Python multiprocessor recovery pool after "Resource temporarily unavailable"

If I create a pool with an unacceptably large number of processes, while in the Python interpreter it will be clearly erroneous, however, it seems that the broken processes are cleared before that, therefore leaving environmental pollution, and the rest of the system cannot process fork processes.

>>> from multiprocessing import Pool
>>> p = Pool(1000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/__init__.py", line 232, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 159, in __init__
    self._repopulate_pool()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 222, in _repopulate_pool
    w.start()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 130, in start
    self._popen = Popen(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/forking.py", line 121, in __init__
    self.pid = os.fork()
OSError: [Errno 35] Resource temporarily unavailable

>>> p = Pool(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/__init__.py", line 232, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 159, in __init__
    self._repopulate_pool()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 222, in _repopulate_pool
    w.start()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 130, in start
    self._popen = Popen(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/forking.py", line 121, in __init__
    self.pid = os.fork()
OSError: [Errno 35] Resource temporarily unavailable

Is there a way to avoid / fix this, or is it considered a mistake?

+5
source share
3 answers

Is there any way to avoid / fix this,

Do not do this.

or is it considered a mistake?

, -, . 2.7, , , - , (2.7.6 : http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS).

, OSX stacktrace. errno 35 ( EAGAIN OSX), forking - 100

, , , . , . , .

+2

, .

Ticket: http://bugs.python.org/issue19675

Python 2.7.8 Mac OS Mavericks

+2

"ulimit -n 2048" , . 2048 . .

0

All Articles