wait for proxy to exit in test_external_proxy

.terminate() only sends the signal,
it doesn't wait for the process to exit.

If the process doesn't exit promptly,
the next instance may try to grab the port before the previous process has released it,
causing failure with EADDRINUSE.
This commit is contained in:
Min RK
2017-11-29 15:22:45 +01:00
parent ee76772e1b
commit cb9f356a69

View File

@@ -66,6 +66,7 @@ def test_external_proxy(request):
def _cleanup_proxy():
if proxy.poll() is None:
proxy.terminate()
proxy.wait(timeout=10)
request.addfinalizer(_cleanup_proxy)
def wait_for_proxy():
@@ -98,6 +99,7 @@ def test_external_proxy(request):
# teardown the proxy and start a new one in the same place
proxy.terminate()
proxy.wait(timeout=10)
proxy = Popen(cmd, env=env)
yield wait_for_proxy()
@@ -115,6 +117,7 @@ def test_external_proxy(request):
# teardown the proxy, and start a new one with different auth and port
proxy.terminate()
proxy.wait(timeout=10)
new_auth_token = 'different!'
env['CONFIGPROXY_AUTH_TOKEN'] = new_auth_token
proxy_port = 55432