[Twisted-Python] Re: GUI responsiveness

Bob Ippolito bob at redivi.com
Wed Sep 14 20:07:21 EDT 2005


On Sep 14, 2005, at 7:35 PM, Jasper wrote:

> Bob Ippolito wrote:
>
>
>>
>> On Sep 14, 2005, at 5:15 PM, Jasper wrote:
>>
>>
>>> Bob Ippolito wrote:
>>>
>>> Hmmm.  Perhaps I glanced over threadedselectreactor too quickly,   
>>> since all the discussion seemed to be about wxPython (which I'm  
>>> not  using).  However, casting about through the archives, I  
>>> haven't  really found a good description of threadedselectreactor...
>>>
>>> What's it actually do?  Just allow you to integrate 2 loops in a   
>>> slightly nicer fashion?  I integrated my pygame+pyui loop with   
>>> twisted's default reactor using 5 simple lines of code, so I'm  
>>> not  seeing much room for gain there...  Does  
>>> threadedselectreactor do  more, like address GUI responsiveness?
>>>
>>> Or more to the point, is there a concise overview somewhere?
>>>
>>
>>
>> http://bob.pythonmac.org/archives/2005/04/17/twisted-and-foreign-  
>> event-loops/
>> http://svn.twistedmatrix.com/cvs/trunk/doc/core/examples/ 
>> threadedselect/
>>
> Heh, I'd seen both of those... Neither really suggest any reason to  
> use threadedselectreactor beyond being able to integrate foreign  
> loops.

That's all the reason you need.  If you're integrating with a foreign  
event loop, you either use a custom specific reactor (most of which  
are broken and/or unmaintained), or you use threadedselectreactor.   
Writing your own custom specific reactor is almost certainly going to  
be broken in some way, and it's more complex code that you have to  
maintain.

> I guess I'm just not seeing what's so great about  
> threadedselectreactor, except perhaps that it's better than wxreactor.

It's better than writing your own reactor for every foreign event  
loop you're interested in, and it's generic enough to integrate with  
ANYTHING that has a thread-safe way to send a message to the main  
runloop (basically, all of them can do that).  Your pygame+pyui loop  
is probably less responsive to either network or user events, or  
perhaps instead chews more CPU than a threadedselectreactor alternative.

Fortunately, there's even an example that demonstrates how you could  
use it in conjunction with pygame.

-bob





More information about the Twisted-Python mailing list