Package twisted :: Package python :: Module threadpool :: Class ThreadPool

[show private | hide private]
[frames | no frames]

## Class ThreadPool

Known Subclasses:
  `ThreadDispatcher`

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)`
| ``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.

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

Method Details

### dispatch(self, owner, func, *args, **kw)

Dispatch a function to be a run in a thread.

owner must be a loggable object.

### 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

Generated by Epydoc 1.1 on Sat Feb 15 21:18:06 2003 | http://epydoc.sf.net