From eb7468059ddb6c2c32d7711417940012e5ea91b7 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 1 Feb 2018 21:22:15 -0800 Subject: [PATCH] Make Daphne process tests try harder. --- tests/http_base.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/http_base.py b/tests/http_base.py index 1772539..fc1f7fe 100644 --- a/tests/http_base.py +++ b/tests/http_base.py @@ -59,14 +59,15 @@ class DaphneTestingInstance: # Optionally enable X-Forwarded-For support. if self.xff: daphne_args += ["--proxy-headers"] - # Start up process and make sure it begins listening. - self.process = subprocess.Popen(daphne_args + ["daphne.test_application:TestApplication"]) - for _ in range(30): - time.sleep(0.1) - if self.port_in_use(self.port): - return self - # Daphne didn't start up. Sadface. - self.process.terminate() + # Start up process and make sure it begins listening. Try this 3 times. + for _ in range(3): + self.process = subprocess.Popen(daphne_args + ["daphne.test_application:TestApplication"]) + for _ in range(30): + time.sleep(0.1) + if self.port_in_use(self.port): + return self + # Daphne didn't start up. Sadface. + self.process.terminate() raise RuntimeError("Daphne never came up.") def __exit__(self, exc_type, exc_value, traceback):