Skip to content

Commit

Permalink
Merge pull request #11 from lsst-sqre/tickets/DM-26303
Browse files Browse the repository at this point in the history
[DM-26303] Allow spawning of lab to give up
  • Loading branch information
cbanek authored Aug 11, 2020
2 parents 12d4e22 + 7ba9049 commit 01816b1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/mobu/jupyterclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,23 @@ async def spawn_lab(self) -> None:
progress_url = r.url
self.log.info(f"Watching progress url {progress_url}")

while True:
# Jupyterlab will give up a spawn after 900 seconds, so we shouldn't
# wait longer than that.
max_poll_secs = 900
poll_interval = 15
retries = max_poll_secs / poll_interval

while retries > 0:
async with self.session.get(progress_url) as r:
if str(r.url) == lab_url:
self.log.info(f"Lab spawned, redirected to {r.url}")
return
else:
self.log.info(f"Still waiting for lab to spawn {r}")
await asyncio.sleep(15)

self.log.info(f"Still waiting for lab to spawn {r}")
retries -= 1
await asyncio.sleep(poll_interval)

raise Exception("Giving up waiting for lab to spawn!")

async def delete_lab(self) -> None:
headers = {"Referer": self.jupyter_url + "hub/home"}
Expand Down

0 comments on commit 01816b1

Please sign in to comment.