Skip to main content

asyncio Eventloop Blockers Detector/Analyzer.

Project description

LoopSentry

Asyncio Event Loop Blockers Detector & Analyzer

  • utility for detecting blocking calls in asyncio event loops

Demo

Installation

uv add loopsentry

pip way

pip install loopsentry

Usage

  1. Basic Usage
import asyncio
from loopsentry import LoopSentry

async def main():
    # start monitoring (default threshold: 0.1s) ie: if blocks is >= 0.1 , it is logged
    sentry = LoopSentry(threshold=0.1)
    sentry.start()

    print("Running...")
    ... # rest of your application

if __name__ == "__main__":
    asyncio.run(main())
  1. Use inside Uvicorn/gunicorn workers in fastapi
  • you need to put it inside a lifespan context manager , so if you use multiple workers eachh gets their own LoopSentry instance
from contextlib import asynccontextmanager
from fastapi import FastAPI
from loopsentry import LoopSentry

@asynccontextmanager
async def lifespan(app: FastAPI):
    sentry = LoopSentry()
    sentry.start()
    yield

app = FastAPI(lifespan=lifespan)

@app.get("/")
async def root():
    return {"message": "I am being monitored!"}

Log Analysis

uv run loopsentry analyze -d log_directory

NOTE: if you used pip to install then

loopsentry analyze -d log_directory

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loopsentry-0.1.0.tar.gz (148.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loopsentry-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file loopsentry-0.1.0.tar.gz.

File metadata

  • Download URL: loopsentry-0.1.0.tar.gz
  • Upload date:
  • Size: 148.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for loopsentry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a643417f1d44dcae5aa71c6901b646076f0f067af1e436b5db0dd31820482cc0
MD5 4b6bab82c3412ae7e4892e6f9c760f72
BLAKE2b-256 e26cfe01a3602ae54100f2bcb5a55b1c6856816c06986ec8c3395fd2cfc19441

See more details on using hashes here.

File details

Details for the file loopsentry-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for loopsentry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ca371e1f6ff95d7a3c2e68097090e5d91f56e343cd6de3730fda1add69679af
MD5 da360af28c7be33a6d848c7a7c764857
BLAKE2b-256 8a36a4e90198c416d25b4d0eefce3ff8e438f53561f527d46c956fde01515770

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page