mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
Make Daphne process tests try harder.
This commit is contained in:
parent
0572b1dbcd
commit
eb7468059d
|
@ -59,14 +59,15 @@ class DaphneTestingInstance:
|
||||||
# Optionally enable X-Forwarded-For support.
|
# Optionally enable X-Forwarded-For support.
|
||||||
if self.xff:
|
if self.xff:
|
||||||
daphne_args += ["--proxy-headers"]
|
daphne_args += ["--proxy-headers"]
|
||||||
# Start up process and make sure it begins listening.
|
# Start up process and make sure it begins listening. Try this 3 times.
|
||||||
self.process = subprocess.Popen(daphne_args + ["daphne.test_application:TestApplication"])
|
for _ in range(3):
|
||||||
for _ in range(30):
|
self.process = subprocess.Popen(daphne_args + ["daphne.test_application:TestApplication"])
|
||||||
time.sleep(0.1)
|
for _ in range(30):
|
||||||
if self.port_in_use(self.port):
|
time.sleep(0.1)
|
||||||
return self
|
if self.port_in_use(self.port):
|
||||||
# Daphne didn't start up. Sadface.
|
return self
|
||||||
self.process.terminate()
|
# Daphne didn't start up. Sadface.
|
||||||
|
self.process.terminate()
|
||||||
raise RuntimeError("Daphne never came up.")
|
raise RuntimeError("Daphne never came up.")
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user