-
-
Save xshapira/d2c76c16ef15e72e396b0f6e40c4090e 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