Bug 1413852 - TcpTransport.receive() doesn't obey current socket timeout.
The getter for socket_timeout should always return the current socket
timeout from the socket instance first, and only fallback to the
private property if no socket instance exists.
This ensures that all methods will always operate on the current
socket timeout value.
Also using a timeout of 2s for receiving the hello string might be too
less for slow running builds. To prevent intermittent failures for
start_session, a good value might be 60s.
MozReview-Commit-ID: HywjFfClrRr
--- a/testing/marionette/client/marionette_driver/transport.py
+++ b/testing/marionette/client/marionette_driver/transport.py
@@ -104,23 +104,27 @@ class TcpTransport(object):
self.protocol = self.min_protocol_level
self.application_type = None
self.last_id = 0
self.expected_response = None
self.sock = None
@property
def socket_timeout(self):
+ if self.sock:
+ return self.sock.gettimeout()
+
return self._socket_timeout
@socket_timeout.setter
def socket_timeout(self, value):
+ self._socket_timeout = value
+
if self.sock:
self.sock.settimeout(value)
- self._socket_timeout = value
def _unmarshal(self, packet):
msg = None
# protocol 3 and above
if self.protocol >= 3:
typ = int(packet[1])
if typ == Command.TYPE:
@@ -187,17 +191,17 @@ class TcpTransport(object):
self.sock.connect((self.addr, self.port))
except:
# Unset self.sock so that the next attempt to send will cause
# another connection attempt.
self.sock = None
raise
- with SocketTimeout(self.sock, 2.0):
+ with SocketTimeout(self.sock, 60.0):
# first packet is always a JSON Object
# which we can use to tell which protocol level we are at
raw = self.receive(unmarshal=False)
hello = json.loads(raw)
self.protocol = hello.get("marionetteProtocol", self.min_protocol_level)
self.application_type = hello.get("applicationType")
return (self.protocol, self.application_type)