The Group class in this module abstracts a group of running greenlets. When a greenlet dies, it’s automatically removed from the group. All running greenlets in a group can be waited on with Group.joinall(), or all running greenlets can be killed with Group.kill().
The Pool class, which is 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.
Bases: gevent.pool.GroupMappingMixin
Maintain a group of greenlets that are still running.
Links to each item and removes it upon notification.
alias of Greenlet
Start the un-started greenlet and add it to the collection of greenlets this group is monitoring.
Begin a new greenlet with the given arguments (which are passed to the greenlet constructor) and add it to the collection of greenlets this group is monitoring.
| Returns: | The newly started greenlet. |
|---|
Bases: gevent.pool.Group
Create a new pool.
A pool is like a group, but the maximum number of members is governed by the size parameter.
| Parameters: | size (int) – If given, this non-negative integer is the maximum count of active greenlets that will be allowed in this pool. A few values have special significance:
|
|---|
Wait until it’s possible to spawn a greenlet in this pool.
| Parameters: | timeout (float) – If given, only wait the specified number of seconds. |
|---|
Warning
If the pool was initialized with a size of 0, this method will block forever unless a timeout is given.
| Returns: | A number indicating how many new greenlets can be put into the pool without blocking. |
|---|
Changed in version 1.1a3: Added the timeout parameter.
Return a boolean indicating whether this pool has any room for members. (True if it does, False if it doesn’t.)
Return a number indicating approximately how many more members can be added to this pool.
Next page: gevent.subprocess