Package twisted :: Package python :: Module threadpool :: Class ThreadPool |
[show private | hide private]
[frames | no frames]

## Class ThreadPool

This class (hopefully) generalizes the functionality of a pool of threads to which work can be dispatched.

dispatch(), dispatchWithCallback() and stop() should only be called from a single thread, unless you make a subclass where stop() and _startSomeWorkers() are synchronized.

Method Summary
| `__init__(self, minthreads, maxthreads)`
| `__getstate__(self)`
| `__setstate__(self, state)`
| `callInThread(self, func, *args, **kw)`
| ``dispatch`(self, owner, func, *args, **kw)` Dispatch a function to be a run in a thread.
| ``dispatchWithCallback`(self, owner, callback, errback, func, *args, **kw)` Dispatch a function, returning the result to a callback function.
| `dumpStats(self)`
| ``start`(self)` Start the threadpool.
| ``stop`(self)` Shutdown the threads in the threadpool.
| `_runWithCallback(self, callback, errback, func, args, kwargs)`
| `_startSomeWorkers(self)`
| `_worker(self)`

Class Variable Summary
`int` | `joined`
`int` | `max`
`int` | `min`
`int` | `started`
`int` | `workers`
`int` | `_ThreadPool__inited`

Method Details

### dispatch(self, owner, func, *args, **kw) Dispatch a function to be a run in a thread.

### dispatchWithCallback(self, owner, callback, errback, func, *args, **kw) Dispatch a function, returning the result to a callback function. The callback function will be called in the thread - make sure it is thread-safe.

### start(self) Start the threadpool.

### stop(self) Shutdown the threads in the threadpool.

Class Variable Details

    ### joined Type: `int` Value:
        0

    ### max Type: `int` Value:
        20

    ### min Type: `int` Value:
        5

    ### started Type: `int` Value:
        0

    ### workers Type: `int` Value:
        0

    ### _ThreadPool__inited Type: `int` Value:
        0

Generated by Epydoc 1.1 on Thu May 8 13:18:57 2003 | http://epydoc.sf.net