From 61a7f80df2095b376196af67f66380414eec3a3c Mon Sep 17 00:00:00 2001 From: Romain Primet Date: Fri, 13 Jul 2018 14:56:00 +0000 Subject: [PATCH] handle 404 and 503 transient errors --- tljh/installer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tljh/installer.py b/tljh/installer.py index 51205e3..611f3c7 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -145,16 +145,16 @@ def ensure_jupyterhub_running(times=4): print('Waiting for JupyterHub to come up ({}/{} tries)'.format(i + 1, times)) urlopen('http://127.0.0.1') return - except URLError as e: - if isinstance(e.reason, ConnectionRefusedError): - # Hub isn't up yet, sleep & loop + except HTTPError as h: + if h.code in [404, 503]: + # May be transient time.sleep(1) continue # Everything else should immediately abort raise - except HTTPError as h: - if h.code in [404, 503]: - # May be transient + except URLError as e: + if isinstance(e.reason, ConnectionRefusedError): + # Hub isn't up yet, sleep & loop time.sleep(1) continue # Everything else should immediately abort