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)
Methods
|
|
__init__
_runWithCallback
dispatchApply
dispatchWithCallback
runInThread
stop
|
|
__init__
|
__init__ (
self,
*args,
*kwargs,
)
|
|
_runWithCallback
|
_runWithCallback (
self,
callback,
errback,
func,
args,
kwargs,
)
|
|
dispatchApply
|
dispatchApply (
self,
owner,
callback,
errback,
func,
args,
kw,
)
|
|
dispatchWithCallback
|
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.
|
|
runInThread
|
runInThread (
self,
callback,
errback,
func,
*args,
*kw,
)
|
|
stop
|
stop ( self )
|
|