From eb19a7304469cf93873c99320a98aed3ea778891 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 9 Nov 2018 13:22:08 +0100 Subject: [PATCH] add Spawner.get_url for retrieving the spawner url. Occurs on startup. Default is a no-op and no Spawner needs to implement this. --- jupyterhub/spawner.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index 6d0d2b9b..3dd141d1 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -661,6 +661,22 @@ class Spawner(LoggingConfigurable): return env + async def get_url(self): + """Get the URL to connect to the server + + Sometimes JupyterHub may ask the Spawner for its url. + This can occur e.g. when JupyterHub has restarted while a server was not finished starting, + giving Spawners a chance to recover the URL where their server is running. + + The default is to trust that JupyterHub has the right information. + Only override this method in Spawners that know how to + check the correct URL for the servers they start. + + This will only be asked of Spawners that claim to be running + (`poll()` returns `None`). + """ + return self.server.url + def template_namespace(self): """Return the template namespace for format-string formatting.