[Twisted-Python] Threadpool analysis?

Andrew Bennetts andrew-twisted at puzzling.org
Wed Apr 11 21:06:42 EDT 2007

Jonathan Vanasco wrote:
> On Apr 11, 2007, at 5:02 PM, Phil Mayers wrote:
> >Why are you using a threadpool with Twisted?
> I'm not using one directly -- I'm using deferToThread , which twisted  
> manages via its own threadpool.  Stuff is locking up, so i'm using  
> manhole to try and see wtf is going on.

Keep in mind that deferToThread uses the reactor's threadpool, which by default
only has a fairly small number of threads.  So if you are trying to run many
long-running operations via deferToThread, it may take a long time for them to
get served.  It may be better to start your own threadpool
(twisted.python.threadpool) if you depend heavily on it.

Also, the easiest way to find out what the state the threads started by a thread
pool are in is by looking at the ThreadPool object; you could inspect the
tp.q.qsize(), len(tp.threads), etc.

You could also look at threading.enumerate() in the standard library.


More information about the Twisted-Python mailing list