Implements interfaces: .IWorker

A composite IWorker implementation.

Method __init__ No summary
Method statistics Gather information on the current status of this Team.
Method grow Increase the the number of idle workers by n.
Method shrink Decrease the number of idle workers by n.
Method do Perform some work in a worker created by createWorker.
Method quit Stop doing work and shut down all idle workers.
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 _coordinator the IExclusiveWorker coordinating access to this Team's internal resources.
Instance Variable _createWorker a callable that will create new workers.
Instance Variable _logException a 0-argument callable called in an exception context when there is an unhandled error from a task passed to Team.do
Instance Variable _idle a set of idle workers.
Instance Variable _busyCount the number of workers currently busy.
Instance Variable _pending a deque of tasks - that is, 0-argument callables passed to Team.do - that are outstanding.
Instance Variable _shouldQuitCoordinator 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 _toShrink the number of workers to shrink this Team by at the next available opportunity; set in the coordinator.
Method _quitIdlers The implmentation of shrink, performed by the coordinator worker.
Method _coordinateThisTask Select a worker to dispatch to, either an idle one or a new one, and perform it.
Method _recycleWorker Called only from coordinator.
_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.
_coordinator =
the IExclusiveWorker coordinating access to this Team's internal resources.
_createWorker =
a callable that will create new workers.
_logException =
a 0-argument callable called in an exception context when there is an unhandled error from a task passed to Team.do
_idle =
a set of idle workers.
_busyCount =
the number of workers currently busy.
_pending =
a deque of tasks - that is, 0-argument callables passed to Team.do - that are outstanding.
_shouldQuitCoordinator =
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.
_toShrink =
the number of workers to shrink this Team by at the next available opportunity; set in the coordinator.
def __init__(self, coordinator, createWorker, logException): (source)
Parameterscoordinatoran 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).
createWorkerA 0-argument callable that will create an IWorker to perform work.
logExceptionA 0-argument callable called in an exception context when the work passed to do raises an exception.
def statistics(self): (source)

Gather information on the current status of this Team.

Returnsa Statistics describing the current state of this Team.
def grow(self, n): (source)

Increase the the number of idle workers by n.

ParametersnThe number of new idle workers to create. (type: int)
def shrink(self, n=None): (source)

Decrease the number of idle workers by n.

ParametersnThe number of idle workers to shut down, or None (or unspecified) to shut down all workers. (type: int or types.NoneType)
def _quitIdlers(self, n=None): (source)

The implmentation of shrink, performed by the coordinator worker.

Parametersnsee Team.shrink
def do(self, task): (source)

Perform some work in a worker created by createWorker.

Parameterstaskthe callable to run
def _coordinateThisTask(self, task): (source)

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.

Parameterstaskthe task to dispatch (type: 0-argument callable)
def _recycleWorker(self, worker): (source)

Called only from coordinator.

Recycle the given worker into the idle pool.

Parametersworkera worker created by createWorker and now idle. (type: IWorker)
def quit(self): (source)

Stop doing work and shut down all idle workers.

API Documentation for Twisted, generated by pydoctor at 2016-04-04 15:02:49.