Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 736 Bytes

File metadata and controls

44 lines (31 loc) · 736 Bytes

logo

Event loop lock detector for Python.


Installation

pip install gadasyncblock

Usage

import contextlib

from fastapi import FastAPI

from gadasyncblock import AsyncBlock
# logger: asyncio.detector

detector = AsyncBlock(timeout=1)

@contextlib.asynccontextmanager
async def lifespan(_: FastAPI):
    detector.start()
    yield
    detector.shutdown()


app = FastAPI(lifespan=lifespan)

@app.post("/run")
async def run():
    time.sleep(2)
    return {"message": "Blocked"}