From d251a645fd93b73a76b71d4122ea958904d5d064 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Tue, 19 Jan 2016 14:44:54 +0000 Subject: [PATCH] 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'. --HG-- extra : rebase_source : a2b72fd1e40142cbae5387193ea828348c8eee5c --- .../marionette/transport/marionette_transport/transport.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testing/marionette/transport/marionette_transport/transport.py b/testing/marionette/transport/marionette_transport/transport.py index 5b8bf5aca42b..28ab714cd6ef 100644 --- a/testing/marionette/transport/marionette_transport/transport.py +++ b/testing/marionette/transport/marionette_transport/transport.py @@ -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