gevent.pool – Managing greenlets in a group

The Group class in this module abstracts a group of running greenlets. When a greenlet dies, it’s automatically removed from the group.

The Pool which a subclass of Group provides a way to limit concurrency: its spawn method blocks if the number of greenlets in the pool has already reached the limit, until there is a free slot.

class gevent.pool.Group(*args)

Maintain a group of greenlets that are still running.

Links to each item and removes it upon notification.

greenlet_class

alias of Greenlet

add(greenlet)
discard(greenlet)
start(greenlet)
spawn(*args, **kwargs)
join(timeout=None, raise_error=False)
kill(exception=<class 'greenlet.GreenletExit'>, block=True, timeout=None)
killone(greenlet, exception=<class 'greenlet.GreenletExit'>, block=True, timeout=None)
apply(func, args=None, kwds=None)

Equivalent of the apply() builtin function. It blocks till the result is ready.

apply_cb(func, args=None, kwds=None, callback=None)
apply_async(func, args=None, kwds=None, callback=None)

A variant of the apply() method which returns a Greenlet object.

If callback is specified then it should be a callable which accepts a single argument. When the result becomes ready callback is applied to it (unless the call failed).

map(func, iterable)
map_cb(func, iterable, callback=None)
map_async(func, iterable, callback=None)

A variant of the map() method which returns a Greenlet object.

If callback is specified then it should be a callable which accepts a single argument.

imap(func, iterable)

An equivalent of itertools.imap()

imap_unordered(func, iterable)

The same as imap() except that the ordering of the results from the returned iterator should be considered in arbitrary order.

full()
wait_available()
class gevent.pool.Pool(size=None, greenlet_class=None)
wait_available()
full()
free_count()
add(greenlet)

Next page: Implementing servers