-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support JupyterHub 2.0 API pagination #30
Conversation
adopt async/await syntax, require Python 3.6 for async generator syntax cull inactive users *before* culling ready servers avoids async race where both paths may try to delete the same user
This comment has been minimized.
This comment has been minimized.
This looks great but think I lack clarity of understanding still of this code because I think the async generators and their use make it quite complicated. I wonder:
I can try follow up and answer these questions myself later, sorry for being lazy not doing the investigation right now myself. |
I'd like to work on this, because I thought it would make it simpler: just like we had one function that produced an iterable of users (a list), we now have one function that produces an iterable of users (a generator that happens to be async). So The code to iterate through users is unchanged, and unaffected by the number of requests it takes to produce the list of users.
Not exactly. There is a semaphore limiting the number of outstanding HTTP requests. This has the approximate effect of limiting concurrent shutdowns, but is not quite the same (if shutdowns take a long time, they are left pending, so can be concurrent with other shutdowns even while an http request is not outstanding, plus requests other than shutdown consume the same concurrency pool)
I don't quite understand what paginating a single user would mean. The only pagination occurs in the request to list users - this may take one request, or it may take 5 (or 50), but once we are processing users, it shouldn't be related The sequence should look like this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM!
I'd like to see a comment about the complexity of users being deleted/added influences the returned pagination results - mainly as an inline note in the code, perhaps also in the README.md if relevant.
Pagination is coming in JupyterHub 2.0, implemented behind an Accept header in jupyterhub/jupyterhub#3535
adds
fetch_paginated
async generator to yield items from a paginated endpointadopt async/await syntax, requiring Python 3.6 for async generator syntax (Python 3.6 was already the baseline in CI, but not specified in package metadata)
cull inactive users before culling ready servers. This should avoid an unlikely async race where both paths may try to delete the same user, but that I triggered running with very small thresholds to test