Custom Spawner "spawn progress" troubleshooting

Hey All,

I’m working on a custom spawner for JupyterHub based on SSH connections - this can mean that the initialization and startup is a little slow while the remote session connects, runs all of the login scripts etc. Because of this, I’d like to use the progress reporting introduced in JuyterHub 0.9 to show users what’s actually going on.

I’ve tried a lot of things to get this working, but to no avail. I’ve checked other spawners and how they do it, and I’ve tried going through the jupyterhub code too but to no avail, I just can’t work out what I need to do to get it to start and then update while the remote server is starting.

The spawner code can be found here: GitHub - VIB-CBD/SSHSpawner - Most of the progress code is local, but a description follows. It’s pretty specific to our environment, but I’m sure there’s also more than a couple of weird bits in it, so any other feedback is always welcome.

Currently what happens is, once a user selects a remote server and hits the “Start” button, a small loading wheel shows, as far as I can tell, right up until the start() function actually returns the (ip, port) tuple. Once that’s returned, then the progress bar shows up, but by that time everything, including the long running parts are done so no useful feedback is given to the user. From other spawners, such as the batchspawner from JupyterHub, it seems like there should be the ability to have this progress updated during the start() function: batchspawner/batchspawner.py at 1decdf259a25c8e33e90de7a5817da11a92c0326 · jupyterhub/batchspawner · GitHub

If anyone can point me in the direction of getting this working, it’d be greatly appreciated.

Cheers,

Kris

You need to implement a progress function:

Since this is called asynchronously for more detailed progress logs you can add a queue to your Spawner. start() can push events to the queue and progress() can consume them. Here’s a couple of examples:

They’re a bit complicated but hopefully it’s enough to give you an idea.

Indeed, my local branch has one, but it never seemed to end up being called.

This looks like it might be what I need. I don’t have any kind of queue/event handler, and from some of the other code I didn’t realize I’d need it. I naïvely assumed that the progress function would be called higher up automatically by JupyterHub.

I’ll give this a go and see if I get what I’m looking for.

Thanks @manics!

1 Like

Yes, progress is called by JupyterHub if a request is made to the progress API (e.g. the “Your server is starting…” page).

This may be the “slow spawn timeout”. JupyterHub waits up until this time before responding to the launch request, and it only visits the progress page if the response is “start requested, but not done starting.” So there is no progress requested if the launch is ‘quick’. I believe the default is 10 seconds. You can immediately redirect to the progress view no matter how fast launch is, if you set:

c.JupyterHub.tornado_settings = {
    "slow_spawn_timeout": 0,
}

I think this will become the default in the future, now that the progress API has proven fairly reliable.