An open API service indexing awesome lists of open source software.

https://github.com/alexdemure/gadasyncblock

Event loop lock detector for Python
https://github.com/alexdemure/gadasyncblock

asgi-lock async-block async-lock event-loop-lock event-loop-lock-detector

Last synced: 3 months ago
JSON representation

Event loop lock detector for Python

Awesome Lists containing this project

README

          



logo


Event loop lock detector for Python.

---

### Installation

```
pip install gadasyncblock
```

### Usage

```python
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"}
```