Created
June 30, 2022 05:33
-
-
Save Kludex/f889f02bb81adf3a8d63176ad4d8bcb1 to your computer and use it in GitHub Desktop.
Increase number of threads available on FastAPI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import anyio | |
from fastapi import FastAPI | |
app = FastAPI() | |
@app.on_event("startup") | |
async def startup(): | |
limiter = anyio.to_thread.current_default_thread_limiter() | |
limiter.total_tokens = 100 | |
@app.get("/") | |
async def home(): | |
print(anyio.to_thread.current_default_thread_limiter().total_tokens) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment