Package twisted :: Package internet :: Module threadtask :: Class ThreadDispatcher

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

## Class ThreadDispatcher

    ThreadPool --+
                 |
                ThreadDispatcher

A thread pool that is integrated with the Twisted event loop.

The difference from ThreadPool is that callbacks are run in the main IO event loop thread, and are thus inherently thread-safe.

You probably want your instance to be shutdown when Twisted is shut down:

       from twisted.internet import reactor
       from twisted.internet import threadtask
       tpool = ThreadDispatcher()
       reactor.addSystemEventTrigger('during', 'shutdown', tpool.stop)

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

Method Details

### 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 main event loop thread.

### stop(self)

Shutdown the threads in the threadpool.

  Overrides:
    `twisted.python.threadpool.ThreadPool.stop` (inherited documentation)

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