[Twisted-Python] Has anybody integrated multiple threadpools into reactor?

Ames Andreas (MPA/DF) Andreas.Ames at tenovis.com
Thu Oct 21 05:45:39 EDT 2004


thanks for the hint.

Glyph Lefkowitz wrote:

> I would strongly recommend against using ThreadPool.  Just use
> callInThread - there is already a pool of worker threads.  Starting
> and stopping threadpools with the reactor is difficult to test and
> easy to get wrong.

Could you elaborate a bit on that?  I have the situation that I have
to wrap two C-libs which are essentially wrappers around proprietary
protocols.  They use blocking networked calls so that I'll want to use
threads to make them play nicely with my twisted app.

Now what I'd like to have is two distinct thread(s/ pools) for them.
One of them would have a threadpool size of 1 (one) because the C-lib
isn't threadsafe and I want implicit serialization without being
forced to synchronize explicitly.  My plan was to use a single thread
(no pool) which blocks on a queue 'till it gets request from the
reactor thread.  When it has accomplished its duties it will use
callFromThread to get the results back to the reactor threads.  Could
you tell me where the pitfalls are you mentioned above in this



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 2667 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20041021/89b36376/attachment.bin 

More information about the Twisted-Python mailing list