-
-
Notifications
You must be signed in to change notification settings - Fork 955
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
Add AnyIO CapacityLimiter docs #2288
Add AnyIO CapacityLimiter docs #2288
Conversation
@@ -47,6 +47,7 @@ nav: | |||
- Exceptions: 'exceptions.md' | |||
- Configuration: 'config.md' | |||
- Test Client: 'testclient.md' | |||
- Sync Threadpools: 'threadpools.md' |
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.
I think it's not that easy to find this in the docs, if you don't know that you should look for the threadpool docs.
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.
Agreed but can't think of a better name right now. @Kludex any ideas?
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.
Concurrency?
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.
Concurrency.
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.
"Sync" threadpools, as opposed to what?
# Set number of threads in threadpool to 100 | ||
anyio.to_thread.current_default_thread_limiter().total_tokens = 100 |
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.
# Set number of threads in threadpool to 100 | |
anyio.to_thread.current_default_thread_limiter().total_tokens = 100 | |
# Set number of threads in threadpool to 100 | |
# Note that this increases the limit for anything using AnyIO, not just Starlette | |
anyio.to_thread.current_default_thread_limiter().total_tokens = 100 |
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.
Devil's advocate: if we document this would it then be breaking change if we start using our own capacity limiter(s), meaning this stops working? I think not, it's okay to break docs to some extent.
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.
We can update the docs when we add the CapacityLimiter to explain this.
@@ -47,6 +47,7 @@ nav: | |||
- Exceptions: 'exceptions.md' | |||
- Configuration: 'config.md' | |||
- Test Client: 'testclient.md' | |||
- Sync Threadpools: 'threadpools.md' |
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.
Agreed but can't think of a better name right now. @Kludex any ideas?
Co-authored-by: Adrian Garcia Badaracco <[email protected]>
from starlette.routing import Route | ||
|
||
# Set number of threads in threadpool to 100 | ||
anyio.to_thread.current_default_thread_limiter().total_tokens = 100 |
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.
Doesn't this needs to be in the lifespan if using multiple workers?
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.
I think each worker will do this, so there’s no difference.
but I can do a quick test to confirm
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.
Each worker runs in a separate process, right?
@aminalaee Do you still want to work on this? |
I'm closing this as stale. Please reopen if you still want to work on it, or if someone else wants to take it over, go ahead. |
Related to #1724
Summary
Checklist