[issue18999] Support different contexts in multiprocessing

Richard Oudkerk report at bugs.python.org
Sun Oct 20 00:28:50 CEST 2013


Richard Oudkerk added the comment:

I guess this should be clarified in the docs, but multiprocessing.pool.Pool is a *class* whose constructor takes a context argument, where as multiprocessing.Pool() is a *bound method* of the default context.  (In previous versions multiprocessing.Pool was a *function*.)

The only reason you might need the context argument is if you have subclassed multiprocessing.pool.Pool.

>>> from multiprocessing import pool, get_context
>>> forkserver = get_context('forkserver')
>>> p = forkserver.Pool()
>>> q = pool.Pool(context=forkserver)
>>> p, q
(<multiprocessing.pool.Pool object at 0xb71f3eec>, <multiprocessing.pool.Pool object at 0xb6edb06c>)

I suppose we could just make the bound methods accept a context argument which (if not None) is used instead of self.

----------
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18999>
_______________________________________


More information about the Python-bugs-list mailing list