class Team: (source)
Constructor: Team(coordinator, createWorker, logException)
Implements interfaces: twisted._threads.IWorker
A composite IWorker implementation.
| Method | __init__ |
No summary |
| Method | do |
Perform some work in a worker created by createWorker. |
| Method | grow |
Increase the the number of idle workers by n. |
| Method | quit |
Stop doing work and shut down all idle workers. |
| Method | shrink |
Decrease the number of idle workers by n. |
| Method | statistics |
Gather information on the current status of this Team. |
| Method | _coordinate |
Select a worker to dispatch to, either an idle one or a new one, and perform it. |
| Method | _quit |
The implmentation of shrink, performed by the coordinator worker. |
| Method | _recycle |
Called only from coordinator. |
| Instance Variable | _busy |
the number of workers currently busy. |
| Instance Variable | _coordinator |
the IExclusiveWorker coordinating access to this Team's internal resources. |
| Instance Variable | _create |
a callable that will create new workers. |
| Instance Variable | _idle |
a set of idle workers. |
| Instance Variable | _log |
a 0-argument callable called in an exception context when there is an unhandled error from a task passed to Team.do |
| Instance Variable | _pending |
a deque of tasks - that is, 0-argument callables passed to Team.do - that are outstanding. |
| Instance Variable | _quit |
A Quit flag indicating whether this Team has been quit yet. This may be set by an arbitrary thread since Team.quit may be called from anywhere. |
| Instance Variable | _should |
A flag indicating that the coordinator should be quit at the next available opportunity. Unlike Team._quit, this flag is only set by the coordinator. |
| Instance Variable | _to |
the number of workers to shrink this Team by at the next available opportunity; set in the coordinator. |
IExclusiveWorker, createWorker: Callable[ [], Optional[ IWorker]], logException: Callable[ [], None]):
(source)
¶
| Parameters | |
coordinator:IExclusiveWorker | an IExclusiveWorker which will coordinate access to resources on this Team; that is to say, an IExclusiveWorker whose do method ensures that its given work will be executed in a mutually exclusive context, not in parallel with other work enqueued by do (although possibly in parallel with the caller). |
createCallable[ | A 0-argument callable that will create an IWorker to perform work. |
logCallable[ | A 0-argument callable called in an exception context when the work passed to do raises an exception. |
Perform some work in a worker created by createWorker.
| Parameters | |
task:Callable[ | the callable to run |
Increase the the number of idle workers by n.
| Parameters | |
n:int | The number of new idle workers to create. |
Decrease the number of idle workers by n.
| Parameters | |
n:int or None | The number of idle workers to shut down, or None (or unspecified) to shut down all workers. |
Gather information on the current status of this Team.
| Returns | |
Statistics | a Statistics describing the current state of this Team. |
Select a worker to dispatch to, either an idle one or a new one, and perform it.
This method should run on the coordinator worker.
| Parameters | |
| task:0-argument callable | the task to dispatch |
The implmentation of shrink, performed by the coordinator worker.
| Parameters | |
n:Optional[ | see Team.shrink |
Called only from coordinator.
Recycle the given worker into the idle pool.
| Parameters | |
worker:IWorker | a worker created by createWorker and now idle. |
a 0-argument callable called in an exception context when there is an unhandled error from a task passed to Team.do
A flag indicating that the coordinator should be quit at the next available opportunity. Unlike Team._quit, this flag is only set by the coordinator.