Bug 1028407 - Establish connection to server faster.;r=jgriffin
There was a 5 second sleep() in the Marionette client. The history of
its value is unclear, but bug comments seem to indicate that Gecko
wasn't completely initialized during the observer notification that
starts the server. We removed the sleep.
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -582,27 +582,30 @@ class Marionette(object):
except socket.error:
return False
finally:
s.close()
def wait_for_port(self, timeout=60):
starttime = datetime.datetime.now()
while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
+ sock = None
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((self.host, self.port))
data = sock.recv(16)
sock.close()
if ':' in data:
- time.sleep(5)
return True
except socket.error:
pass
- time.sleep(1)
+ finally:
+ if sock:
+ sock.close()
+ time.sleep(.1)
return False
@do_crash_check
def _send_message(self, command, response_key="ok", **kwargs):
if not self.session and command != "newSession":
raise errors.MarionetteException("Please start a session")
message = {"name": command}