

def __init__(self, max_resources, factory):
    "Create a new MultiResource, use 'factory' to create new resources.\n\n        Will call 'factory' at most 'max_resources' times.\n        Note that 'factory' must be multiprocess-safe.\n\n        :max_resources: integer\n        :factory: a callable that returns a new resource\n\n        "
    if (max_resources < 1):
        raise ValueError('max_resources should be at least 1, got {}'.format(max_resources))
    self._factory = factory
    mp = multiprocessing
    self._free_resources = mp.queues.SimpleQueue()
    for _ in xrange(max_resources):
        self._free_resources.put(_NotAResource)

dataset/ETHPy150Open bloomberg/phabricator-tools/py/phl/phlsys_multiprocessing.py MultiResource.__init__/original