Skip to content

Commit

Permalink
Merge pull request #27 from mriedem/26-request-timeout
Browse files Browse the repository at this point in the history
Change default request_timeout and allow override
  • Loading branch information
minrk authored May 14, 2021
2 parents 78d9196 + 2f68488 commit c13e42c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 8 additions & 1 deletion jupyterhub_idle_culler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:
Expand Down

0 comments on commit c13e42c

Please sign in to comment.