asynqueue.threads.PoolUser(object)
class documentation
Part of asynqueue.threads
(View In Hierarchy)
Known subclasses: asynqueue.threads.IterationGetter, asynqueue.threads.OrderedItemProducer
Abstract base class for objects that access a global thread pool instead of starting their own threads.
Class Method | setup | Sets up stuff class-wide, with all the potential pitfalls that entails. |
Class Method | shutdown | Shuts down all threads, returning a Deferred that fires
when everything's done, class-wide. |
Class Method | deferToThreadInPool | Runs the f-args-kw call combo in one of my threads,
returning a Deferred that fires with the eventual result. Can
be run from the class or any instance of me with the exact same result. |
Method | pool | Returns a reference to the class-wide threadpool, starting it if this is the first time it's been used. |
def setup(cls, maxThreads=None):
Sets up stuff class-wide, with all the potential pitfalls that entails.
Sets up all present and future instances of Consumerator
,
Filerator
, OrderedItemProducer
,
and any other subclasses of me with a thread pool having at least two and
no more than maxThreads threads.
If this method is called with a thread pool already instantiated, and maxThreads is specified and different from the current value, it adjusts the maximum thread pool size for all instances, current and future, absent yet another call with still different values.
Parameters | maxThreads | Set to a maximum number of threads to use, for all present and future instances. |
Note | In the several years that have gone by since I wrote this, I realized that it's almost always a terrible idea to make class-wide settings of anything. But it's mature code and hasn't given me any trouble. |
def shutdown(cls):
Shuts down all threads, returning a Deferred
that fires
when everything's done, class-wide.