[Twisted-Python] Triggering callbacks on raw file descriptors

James Y Knight foom at fuhm.net
Mon Jan 9 00:41:58 EST 2006


On Jan 8, 2006, at 1:46 AM, Brian Granger wrote:
> When I killed the reactor, I got an exception:
>
> exceptions.AttributeError: 'BonjourDescriptor' object has no  
> attribute 'connectionLost'
>
> It looks like the disconnectAll method on the reactor is calling  
> reader.connectionLost on each reader.  Why is this so?
> I thought I only needed to implement the IReadDescriptor interface  
> for my reader, but the connectionLost method is not a part of that  
> interface.  Hmmm.  Should I implement it?  What interface is that  
> method in?  This seems confusing.

connectionLost should have been on IFileDescriptor, the superclass of  
IReadDescriptor. I just added it:
>     def connectionLost(self, reason):
>         """Called when the connection was lost.
>
>         This is called when the connection on a selectable object  
> has been
>         lost.  It will be called whether the connection was closed  
> explicitly,
>         an exception occurred in an event handler, or the other end  
> of the
>         connection closed it first.
>
>         See also L{IHalfCloseableDescriptor} if your descriptor  
> wants to be
>         notified separately of the two halves of the connection  
> being closed.
>
>         @param reason: A failure instance indicating the reason why  
> the
>          connection was lost.  L 
> {twisted.internet.error.ConnectionLost} and
>          L{twisted.internet.error.ConnectionDone} are of special  
> note, but
>          the failure may be of other classes as well.
>         """

Hope that helps.

JP seems to disagree that it _should_ be part of the interface  
(http://twistedmatrix.com/bugs/issue1408), but it _is_ currently (and  
was previously, just undocumentedly so).

James




More information about the Twisted-Python mailing list