[Twisted-Python] calling reactor.run() twice in PB app

Eric Smith eric+twisted at trueblade.com
Wed Feb 15 22:25:12 EST 2006

Glyph Lefkowitz wrote:

 >> If anyone could summarize the problem, and if you're serious about 
it getting fixed, I could look at it.

 > Unfortunately this is not a simple problem.  It involves auditing every
 > aspect of the reactor's internal state, including the threadpool, and
 > validating that its internal state is consistent before terminating
 > run().  It also means making sure that every buffer is flushed, all
 > outstanding bytes are read, etc.  Then you have to do that for each
 > reactor.  You'd also have to add an API that specifically did this kind
 > of "soft" shutdown; flushing buffers without closing connections,
 > stopping all threads, and so forth.

Mission accomplished!  You've scared me away from even wanting to do 
this!  Actually I think I'll poke around a bit.  I did spend all day 
reading the posix reactor code, and your comments here are helpful.

I think you're correct about using popen(), since I really just want 
this to work in the near future.  The data is simple enough that I think 
I can just print repr() of the data and eval it on the reader side (I 
know, I know ...).

But another thought I had was a non-twisted python implementation of PB, 
blocking on the socket calls since I'm just doing request-response.  But 
I'm guessing that would be non-trivial as well.

 > However, it would certainly be a great way to learn the ins and outs of
 > the reactor API.  I don't particularly want the functionality but I
 > suspect that adding it will flush out some latent bugs in at least one
 > reactor implementation, so I'm not opposed to seeing it done.
 > If you would like to work on something else though, we definitely need a
 > dedicated Windows maintainer ... ;)

Well, I've written Win32 and IOCP, but I currently focus on Linux. Given 
that I don't work much with Windows any more (at least not when I can 
avoid it), I don't think I'd be a good Windows maintainer, sorry. But 
I'm willing to help where I can.

Thanks for the comments.  Are you going to PyCon?  Maybe I'll bump into 
you there.  I enjoyed your talks in years past.


More information about the Twisted-Python mailing list