Event loop lock detector for Python.
pip install gadasyncblock
import contextlib
from fastapi import FastAPI
from gadasyncblock import AsyncBlock
detector = AsyncBlock(timeout=1)
@contextlib.asynccontextmanager
async def lifespan(_: FastAPI):
await detector.start()
yield
await detector.shutdown()
app = FastAPI(lifespan=lifespan)
@app.post("/run")
async def run():
time.sleep(2)
return {"message": "Blocked"}