asynqueue.threads
module documentation
Part of asynqueue
ThreadQueue
, ThreadWorker
and their support staff. Also, a cool implementation of the oft-desired
deferToThread
, in ThreadQueue.deferToThread
.
Function | deferToThread | Module-level function that lets you call a function in a dedicated
thread and get a Deferred to its result, with no fuss on your
part. |
Class | ThreadQueue | I am a TaskQueue for
dispatching arbitrary callables to be run by a single worker thread. |
Class | ThreadLooper | I run function calls in a dedicated thread. |
Class | PoolUser | Abstract base class for objects that access a global thread pool instead of starting their own threads. |
Class | IterationGetter | Abstract base class for objects that munch data on one end and act like iterators to yield it on the other end. |
Class | Consumerator | I act like an IConsumer for your Twisted code and an
iterator for your blocking code running via a ThreadWorker . |
Class | Filerator | Stream data to me in one end and I will iterate it out the other. |
Class | OrderedItemProducer | Produces blocking iterations in the order they are requested via an asynchronous function call. |
Module-level function that lets you call a function in a dedicated
thread and get a Deferred
to its result, with no fuss on your
part.
The thread will remain alive and will be used for further calls to this function and this function only.
Call with f, *args, and **kw as usual.
This is AsynQueue's single-threaded, queued, doNext-able, iteration.Deferator
-able
answer to Twisted's deferToThread
.
If you expect a deferred iterator as your result (an instance of iteration.Deferator
),
supply an IConsumer
implementor via the consumer
keyword. Each iteration will be written to it, and the deferred will fire
when the iterations are done. Otherwise, the deferred will fire with an iteration.Deferator
.
If you want to kill the dedicated thread, just call this function with
no arguments, not even a callable object f. A Deferred
will be returned that fires when the thread is gone.