Skip to content

Instantly share code, notes, and snippets.

@xshapira
Forked from Kludex/main.py
Created August 26, 2022 08:47
Show Gist options
  • Save xshapira/d2c76c16ef15e72e396b0f6e40c4090e to your computer and use it in GitHub Desktop.
Save xshapira/d2c76c16ef15e72e396b0f6e40c4090e to your computer and use it in GitHub Desktop.
Increase number of threads available on FastAPI.
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