Mybinder.org timeout

Hi,
I am using mybinder.org to host some simulations that I am using for a lab course forced online by the COVID pandemic. In general, this is working quite well, and an example can be found at: https://tinyurl.com/yxr8493h

But, a persistent problem for the students is that page times out after a short time of inactivity, on the order of 5 minutes or so. Because the simulated experiments require some intermediate calculations, having to restart the application, and repeat some of the steps, can be quite frustrating.

Is there anyway to keep this from happening? Perhaps, by running a dummy process in the background?

Thanks,
David

The timeout by default is 10 minutes.

You could use threading or multiprocessing to keep a simple dummy process going in the active kernel background upon launch of your Voila dashboard so for the first 25 minutes or so it will be active and not time out. See this thread for sort of the inverse reason to use threading/multiprocessing.

Wayne,
Thanks very much for your reply. I’m afraid that I’m not having very much luck with either threading or multiprocessing, probably because I don’t understand either very well.

For both, I have created the function background:

def background():
‘’‘Background task to keep keep the page from timing out on mybinder’’’
while True:
sleep(0.1)
abs_show(abs_read)
return

All that this does is update the value of an HTML ipywidget.

For threading, I have included the code:
thread = threading.Thread(target=background)
thread.start()

This runs, but doesn’t seem to do anything to keep the binder page alive beyond 10 minutes.

For multiprocessing, I have tried:
p = Process(target=background)
p.start()
p.join()

When I run this locally, p returns:

which doesn’t seem very good.
But, on mybinder, the result is even worse, with everything freezing up!

Any suggestions would be greatly appreciated!

Thanks,
David

I realized it probably freezes up when launched in Voila, because code that kicks off when Voila starts has to get to a ‘done’ state with something to render before displaying. So that isn’t going to help you unless you still get your students to do something to kick off the background function after the Voila page rendering is completed, I think. I sort of forgot about Voila needing the rendered output completed to display.
You could verify for yourself that the idea of your students kicking off the background function is going to work by using that Timer notebook I linked to in the other thread. I just ran it for 23 minutes and the connection for the session is still good. (You need to adjust the limit for the timeit() and __init__() functions to run longer than 180 seconds.)
Another trick to keep it going longer is to open a terminal first before launching the Voila rendering but that sort of defeats the link to kick things off easily for novices.

Unless you can get your students to at least interact with something first…
I think you’re back to what I was hoping to avoid telling you. You’d need to run your own JupyterHub or Binderhub to have it not time out after 10 minutes with no interaction.

You’d want your background() function to do something and then sleep for like 8 minutes then do something again. Sleeping only a fraction of second is overkill (or may get you flagged on MyBinderas a bitcoin miner)?

Down the road, it would be easier if you shared your code in a way that can be copied and run. Either use tick marks to put code in the markdown, see ’ Block code formatting’ here or post links to snippets as a gist or at pastebin or something like that.
Or better yet put the notebook draft at one your Voila enabled repos and link to both the github page and a launch URL.

1 Like

Wayne,
Thanks again for your comments. I am looking into ways of offering the notebooks locally, which will likely be the best solutions.

I did try to format my code snippets as such, and thought that I remembered a tool here to do that. I didn’t think of the simple Markdown way!

def background():
    '’‘Background task to keep keep the page from timing out on mybinder’’’
    while True:
        sleep(0.1)
        abs_show(abs_read)
    return

Thanks,
David

1 Like

The Littlest JupyterHub offers lots of ways of setting up a hub that you can control.

Yes, it isn’t readily apparent that Discourse allows markdown in posts until you see someone else use it.

I should have mentioned Gesis Notebooks here. If you look under ‘What are the service’s restrictions’ in the FAQ, you’ll see for users signed up for the service and signed in (authenticated users) the timeout for inactivity is 40 minutes.