[Twisted-Python] t.test.proto_helpers.StringTransportWithDisconnection.connectionLost

2013-05-22 Thread Adi Roiban
Hi,



In proto_helpers, StringTransportWithDisconnection is implemented as:

class StringTransportWithDisconnection(StringTransport):
def loseConnection(self):
if self.connected:
self.connected = False
self.protocol.connectionLost(error.ConnectionDone(Bye.))


In the API, I see that for IProtocol.connectionLost(reason), readon
should be a Failure and not an Exception.

http://twistedmatrix.com/documents/13.0.0/api/twisted.internet.interfaces.IProtocol.html#connectionLost

--

Also checking some real code in protocols.ftp shows that reason should
be a Failure, as it uses reason.check() method.

https://github.com/twisted/twisted/blob/trunk/twisted/protocols/ftp.py#L2269

--


Is this a bug in the current implementation of
StringTransportWithDisconnection?

Many thanks,
-- 
Adi Roiban

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.test.proto_helpers.StringTransportWithDisconnection.connectionLost

2013-05-22 Thread Glyph

On May 22, 2013, at 12:01 AM, Adi Roiban a...@roiban.ro wrote:

 Is this a bug in the current implementation of
 StringTransportWithDisconnection?

Yes.  Good catch.  Please look to see if the ticket has already been filed, and 
if not, file one (ideally with a patch!)

-glyph___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.test.proto_helpers.StringTransportWithDisconnection.connectionLost

2013-05-22 Thread Laurens Van Houtven
On Wed, May 22, 2013 at 1:47 PM, Adi Roiban a...@roiban.ro wrote:

 Thanks. Did that. http://twistedmatrix.com/trac/ticket/6521


Awesome, thank you :)


 I have a test which always fails when running `trial twisted.test` but
 pass if executed as an individual tests this is due to a failure
 which is only raised at garbage collection.


Wait, related to this problem? I would expect the test to just try and use
the thing that comes out as a Failure, and check that it's of the
appropriate type... I don't understand how GC comes in to play. Could you
provide said test?

cheers
lvh
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.test.proto_helpers.StringTransportWithDisconnection.connectionLost

2013-05-22 Thread Adi Roiban
[snip]

 I have a test which always fails when running `trial twisted.test` but
 pass if executed as an individual tests this is due to a failure
 which is only raised at garbage collection.


 Wait, related to this problem? I would expect the test to just try and use
 the thing that comes out as a Failure, and check that it's of the
 appropriate type... I don't understand how GC comes in to play. Could you
 provide said test?


I remember reading somewhere (maybe official documentation) that
unhandled deferred which have a failure as a result are only logged at
reactor shutdown or when some garbage collection process take place.
I thought that this is the reason why the tests is failing.

I have added the details of the test in the ticket.

Thanks for the commment!
-- 
Adi Roiban

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python