[Twisted-Python] Re: Taking a look at pending deferToThread actions

Allen Bierbaum abierbaum at gmail.com
Tue Jun 5 12:02:16 EDT 2007

Sorry for answering my own question, but I found a way to get this
information and I thought it may be helpful for other users.

threadpool = reactor.threadpool
num_threads = threadpool.workers
q_size  = threadpool.q.qsize()

num_threads is a good approximation of how many functions are
currently active, and q_size is the number still pending.

Now for another question:

- Has anyone extended threadpool to allow code to remove queued
functions from the pending queue?

I need this capability so I can cull off pending queries that are not
still needed.


On 6/4/07, Allen Bierbaum <abierbaum at gmail.com> wrote:
> I am using deferToThread in my application to put a number of web
> service queries into the background and then respond to them when they
> are complete.  This is all working very well, but once in a while I
> seem to overload the web service with queries and I would like to
> track this down by checking to see how many queries are in flight and
> how many are still waiting to be processed.
> One I have put an action into the background using deferToThread, is
> there a way to check to see how many functions are currently
> processing and similarly how many functions are waiting to be
> processed?
> Thanks,
> Allen

More information about the Twisted-Python mailing list