commit f69452eac1cf5334ab84caab260cbfcaf3adc2dd Author: Isis Lovecruft isis@torproject.org Date: Thu Feb 28 18:35:49 2013 +0000
Switch to using threads.deferToThread() in method deferMakeConnection(). --- nettests/experimental/tls_handshake.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py index 48902b3..ddef435 100644 --- a/nettests/experimental/tls_handshake.py +++ b/nettests/experimental/tls_handshake.py @@ -696,15 +696,23 @@ class TLSHandshakeTest(nettest.NetTestCase): self.report['host'] = host self.report['port'] = port
- @defer.inlineCallbacks - def deferMakeConnection(host): - connection = yield makeConnection(host) - if isinstance(connection, Failure) \ - or isinstance(connection, Exception): - failed = connectionFailed(connection, host) - defer.returnValue(failed) + if isinstance(connection, Exception) \ + or isinstance(connection, ConnectionTimeout): + log.msg("Handshake failed with reason: %s" % connection.message) + self.report['state'] = connection.message + elif isinstance(connection, failure.Failure): + log.msg("Handshake failed with reason: Socket %s" + % connection.getErrorMessage()) + self.report['state'] = connection.getErrorMessage() + ctmo = connection.trap(ConnectionTimeout) + if ctmo == ConnectionTimeout: + connection.cleanFailure() else: - defer.returnValue(connection) + log.msg("Handshake failed with reason: %s" % str(connection)) + if not 'state' in self.report.keys(): + self.report['state'] = str(connection) + + return None
connection = deferMakeConnection(self.input) connection.addCallbacks(connectionSucceeded, connectionFailed,