[Twisted-Python] question about thread and threadpool

the document said: # run method in thread reactor.callInThread(aSillyBlockingMethod, "2 seconds have passed") but after above code, Is that Thread dead? and how can I re-use this thread? and if I create a thread using python thread module, can I use reactor to re-use it? there is a threadpool in twisted, is there any example of how to use it? thanks for any advices.

On Wed, 21 Mar 2007 10:01:11 +0800, wang wei <wgwigw@gmail.com> wrote:
the document said: # run method in thread reactor.callInThread(aSillyBlockingMethod, "2 seconds have passed") but after above code, Is that Thread dead? and how can I re-use this thread? and if I create a thread using python thread module, can I use reactor to re-use it? there is a threadpool in twisted, is there any example of how to use it? thanks for any advices.
callInThread uses a threadpool. If you use it again after the first function finishes, it is quite likely that the same thread will be used to service the second request. If you want, you can also create your own twisted.python.threadpool.ThreadPool instance and dispatch calls to it. Jean-Paul

2007/3/21, Jean-Paul Calderone <exarkun@divmod.com>:
the document said: # run method in thread reactor.callInThread(aSillyBlockingMethod, "2 seconds have passed") but after above code, Is that Thread dead? and how can I re-use this
On Wed, 21 Mar 2007 10:01:11 +0800, wang wei <wgwigw@gmail.com> wrote: thread?
and if I create a thread using python thread module, can I use reactor to re-use it? there is a threadpool in twisted, is there any example of how to use it? thanks for any advices.
callInThread uses a threadpool. If you use it again after the first function finishes, it is quite likely that the same thread will be used to service the second request.
If you want, you can also create your own twisted.python.threadpool.ThreadPool instance and dispatch calls to it.
Jean-Paul
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
thanks, I get the idea. Is there any examples on how to use it?
participants (2)
-
Jean-Paul Calderone
-
wang wei