Bug 1240610 - Align socket_timeout with Python's socket interface; r=automatedtester

When socket.settimeout(None) is set in Python's standard library this
is meant to be equivalent to disabling timeouts on socket operations.
marionette.transport should respect this.

This change set unbreaks the use of the --jdebugger flag to `./mach
marionette-test'.
This commit is contained in:
Andreas Tolfsen 2016-01-19 14:44:54 +00:00
parent 270ff9c1d7
commit cb10a0d7bc

View File

@ -116,6 +116,10 @@ class TcpTransport(object):
connection_lost_msg = "Connection to Marionette server is lost. Check gecko.log (desktop firefox) or logcat (b2g) for errors."
def __init__(self, addr, port, socket_timeout=360.0):
"""If `socket_timeout` is `0` or `0.0`, non-blocking socket mode
will be used. Setting it to `1` or `None` disables timeouts on
socket operations altogether.
"""
self.addr = addr
self.port = port
self.socket_timeout = socket_timeout
@ -164,7 +168,7 @@ class TcpTransport(object):
data = ""
bytes_to_recv = 10
while time.time() - now < self.socket_timeout:
while self.socket_timeout is None or (time.time() - now < self.socket_timeout):
try:
chunk = self.sock.recv(bytes_to_recv)
data += chunk