diff --git a/README.md b/README.md index e430ef2..494e922 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,6 @@ The command line interface also gives a quick overview of the different options users and users' servers. If you want a different value for users and servers, you should add this script to the services list twice, just with different `name`s, different values, and one with the `--cull-users` option. + +3. By default HTTP requests to the hub timeout after 60 seconds. This can be + changed by setting the `JUPYTERHUB_REQUEST_TIMEOUT` environment variable. diff --git a/jupyterhub_idle_culler/__init__.py b/jupyterhub_idle_culler/__init__.py index 3794c9c..048f7e8 100755 --- a/jupyterhub_idle_culler/__init__.py +++ b/jupyterhub_idle_culler/__init__.py @@ -90,6 +90,12 @@ def cull_idle( If cull_users, inactive *users* will be deleted as well. """ + defaults = { + # GET /users may be slow if there are thousands of users and we + # don't do any server side filtering so default request timeouts + # to 60 seconds rather than tornado's 20 second default. + "request_timeout": os.environ.get("JUPYTERHUB_REQUEST_TIMEOUT", 60) + } if ssl_enabled: ssl_context = make_ssl_context( f"{internal_certs_location}/hub-internal/hub-internal.key", @@ -99,8 +105,9 @@ def cull_idle( app_log.debug("ssl_enabled is Enabled: %s", ssl_enabled) app_log.debug("internal_certs_location is %s", internal_certs_location) - AsyncHTTPClient.configure(None, defaults={"ssl_options": ssl_context}) + defaults["ssl_options"] = ssl_context + AsyncHTTPClient.configure(None, defaults=defaults) client = AsyncHTTPClient() if concurrency: