asynqueue.workers.ThreadWorker(object)
class documentation
Part of asynqueue.workers
(View In Hierarchy)
Implements interfaces: IWorker
I implement an IWorker
that runs
tasks in a dedicated worker thread.
Parameters | series | A list of one or more task series that this particular instance of me is qualified to handle. |
raw | Set True if you want raw iterators to be returned instead of
iteration.Deferator
instances. You can override this in with the same keyword set
False in a call. |
Class Variable | cQualified | A task series that all instances of me are qualified to perform. |
Instance Variable | iQualified | A task series that this instance of me is qualified to perform. Usually left blank, unless you want only some workers doing certain tasks. |
Instance Variable | tasks | A list of pending tasks. |
Instance Variable | t | An instance of ThreadLooper . |
Method | __init__ | ThreadWorker (series=[], raw=False) |
Method | setResignator | Undocumented |
Method | run | Returns a Deferred that fires only after the threaded call
is done for the supplied task. |
Method | stop | Returns a Deferred that fires when all pending tasks have
been run, the task loop has ended and its thread has terminated. |
Method | crash | Since a thread can only terminate itself, calling this method only
forces firing of the deferred returned from a previous call to stop and
returns the task that hung the thread. |
Returns a Deferred
that fires only after the threaded call
is done for the supplied task.
I do basic FIFO queuing of calls to this method, but priority queuing is
above my paygrade and you'd best honor my deferred and let someone like tasks.TaskHandler
only call this method when I say I'm ready.
One simple thing I will do is apply the doNext keyword to
any task with the highest priority, -20 or lower (for a base.TaskQueue.call
with its own doNext keyword set). If you call this method one task
at a time like you're supposed to, even that won't make a difference,
except that it will cut in front of any existing call with doNext
set. So use judiciously.
Returns a Deferred
that fires when all pending tasks have
been run, the task loop has ended and its thread has terminated.
Waits for all pending tasks to finish because they run in the task loop and can't do so once the task loop has ended. So the list of outstanding tasks that is the deferred result should always be empty.
Since a thread can only terminate itself, calling this method only
forces firing of the deferred returned from a previous call to stop
and
returns the task that hung the thread.