def __init__(self): super(GreenFuture, self).__init__() eu.check_for_eventlet(RuntimeError('Eventlet is needed to use a green' ' future')) # NOTE(harlowja): replace the built-in condition with a greenthread # compatible one so that when getting the result of this future the # functions will correctly yield to eventlet. If this is not done then # waiting on the future never actually causes the greenthreads to run # and thus you wait for infinity. if not greenpatcher.is_monkey_patched('threading'): self._condition = greenthreading.Condition()
def __init__(self, max_workers=1000): eu.check_for_eventlet( RuntimeError('Eventlet is needed to use a green' ' executor')) if max_workers <= 0: raise ValueError("Max workers must be greater than zero") self._max_workers = max_workers self._pool = greenpool.GreenPool(self._max_workers) self._delayed_work = greenqueue.Queue() self._shutdown_lock = greenthreading.Lock() self._shutdown = False self._gatherer = _Gatherer(self._submit, lock_cls=greenthreading.Lock)
def __init__(self, max_workers=1000): eu.check_for_eventlet(RuntimeError('Eventlet is needed to use a green' ' executor')) if max_workers <= 0: raise ValueError("Max workers must be greater than zero") self._max_workers = max_workers self._pool = greenpool.GreenPool(self._max_workers) self._delayed_work = greenqueue.Queue() self._shutdown_lock = greenthreading.Lock() self._shutdown = False self._gatherer = _Gatherer(self._submit, lock_cls=greenthreading.Lock)
def _wait_for_any_green(fs, timeout=None): eu.check_for_eventlet(RuntimeError('Eventlet is needed to wait on' ' green futures')) with _base._AcquireFutures(fs): done, not_done = _partition_futures(fs) if done: return _base.DoneAndNotDoneFutures(done, not_done) waiter = _GreenWaiter() for f in fs: f._waiters.append(waiter) waiter.event.wait(timeout) for f in fs: f._waiters.remove(waiter) with _base._AcquireFutures(fs): done, not_done = _partition_futures(fs) return _base.DoneAndNotDoneFutures(done, not_done)