Skip to content

Instantly share code, notes, and snippets.

@Kludex
Created June 30, 2022 05:33
Show Gist options
  • Save Kludex/f889f02bb81adf3a8d63176ad4d8bcb1 to your computer and use it in GitHub Desktop.
Save Kludex/f889f02bb81adf3a8d63176ad4d8bcb1 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