[Twisted-Python] CFReactor

James Y Knight foom at fuhm.net
Tue Oct 26 13:04:39 EDT 2004


On Oct 25, 2004, at 6:02 PM, Bob Ippolito wrote:
> On Oct 25, 2004, at 17:24, James Y Knight wrote:
>
>> Itamar just added half-closing support to Twisted, and I foolishly 
>> volunteered to look at adding support to cfreactor for him. However, 
>> that was before I looked at it. Now that I have, I have little idea 
>> what it's actually doing, so I'm afraid that I'm unable to actually 
>> implement this change.
>>
>> The "SelectableSocketWrapper" looks like a horrible kludge, and I'm 
>> not sure why it's necessary. Why does it override the wrapped 
>> object's "connectionLost"? Why do you have to wrap&override 
>> Selectable.start/stopReading/Writing, instead of doing that stuff in 
>> reactor.add/removeReader/Writer? What is simulate?? Essentially, I 
>> just don't understand why it is so different from the other reactors.
>
> The SSW kludge is necessary because it inherits a lot of functionality 
> from the existing default select-based reactor and its sockets.  It is 
> a workaround for the lack of extensibility in the implementation of 
> those sockets and that reactor.  It could be less hacky if it were 
> inverted, but then you'd have to subclass every possible port and add 
> the reactor notifications, and essentially copy about 80% of 
> twisted.internet.default instead of subclassing it.  If you want to 
> refactor it this way, be my guest.. but I'm not bored enough to do it 
> :)
>
> The reason for the loseConnection hack is that the existing 
> implementation of loseConnection doesn't do removeReader/Writer!  
> loseConnection effectively kills the socket without notifying the 
> reactor at all.  If the existing implementation told the reactor when 
> it was done with a socket, SSW wouldn't be so much of a kludge.

Er, I don't believe you. If that was the case, it would be a huge fd 
leak, which I'm pretty sure Twisted doesn't have. I removed that hack 
and I don't think anything further broke.

Anyways, I've changed cfreactor to do what I think should be the right 
thing, but it's randomly failing tests. Before my changes it was 
failing a lot of tests too, so I don't know if this is a regression or 
not.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfreactor.diff
Type: application/octet-stream
Size: 2726 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20041026/fd6d500f/attachment.obj 
-------------- next part --------------


James


More information about the Twisted-Python mailing list