mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
return http response from wait_for_http_server
This commit is contained in:
@@ -111,13 +111,12 @@ class Server(HasTraits):
|
|||||||
return self.url.replace(self._connect_ip, self.ip or '*', 1)
|
return self.url.replace(self._connect_ip, self.ip or '*', 1)
|
||||||
return self.url
|
return self.url
|
||||||
|
|
||||||
@gen.coroutine
|
|
||||||
def wait_up(self, timeout=10, http=False):
|
def wait_up(self, timeout=10, http=False):
|
||||||
"""Wait for this server to come up"""
|
"""Wait for this server to come up"""
|
||||||
if http:
|
if http:
|
||||||
yield wait_for_http_server(self.url, timeout=timeout)
|
return wait_for_http_server(self.url, timeout=timeout)
|
||||||
else:
|
else:
|
||||||
yield wait_for_server(self._connect_ip, self.port, timeout=timeout)
|
return wait_for_server(self._connect_ip, self.port, timeout=timeout)
|
||||||
|
|
||||||
def is_up(self):
|
def is_up(self):
|
||||||
"""Is the server accepting connections?"""
|
"""Is the server accepting connections?"""
|
||||||
|
@@ -89,13 +89,13 @@ def wait_for_http_server(url, timeout=10):
|
|||||||
yield gen.sleep(0.1)
|
yield gen.sleep(0.1)
|
||||||
else:
|
else:
|
||||||
app_log.debug("Server at %s responded with %s", url, e.code)
|
app_log.debug("Server at %s responded with %s", url, e.code)
|
||||||
return
|
return e.response
|
||||||
except (OSError, socket.error) as e:
|
except (OSError, socket.error) as e:
|
||||||
if e.errno not in {errno.ECONNABORTED, errno.ECONNREFUSED, errno.ECONNRESET}:
|
if e.errno not in {errno.ECONNABORTED, errno.ECONNREFUSED, errno.ECONNRESET}:
|
||||||
app_log.warning("Failed to connect to %s (%s)", url, e)
|
app_log.warning("Failed to connect to %s (%s)", url, e)
|
||||||
yield gen.sleep(0.1)
|
yield gen.sleep(0.1)
|
||||||
else:
|
else:
|
||||||
return
|
return r
|
||||||
|
|
||||||
raise TimeoutError(
|
raise TimeoutError(
|
||||||
"Server at {url} didn't respond in {timeout} seconds".format(**locals())
|
"Server at {url} didn't respond in {timeout} seconds".format(**locals())
|
||||||
|
Reference in New Issue
Block a user