Skip to main content

A simple IOC / Dependency injection micro framework for Python.

Project description

fdleaky

A Python utility for detecting file descriptor leaks in Python applications. fdleaky monitors file and socket operations in your application and reports any resources that remain open longer than expected.

Upon suspicion of unclosed File Descriptors being present, hit p in the terminal to print stack traces for the point at which each file descriptor was opened.

Purpose

File descriptor leaks can be difficult to track down, especially in long-running applications. These leaks can lead to:

  • Resource exhaustion
  • "Too many open files" errors
  • Degraded system performance
  • Memory leaks

fdleaky helps you find these issues by:

  • Tracking all file and socket operations
  • Recording stack traces when resources are opened
  • Detecting resources that remain open too long
  • Reporting unclosed resources on shutdown

Installation

pip install fdleaky

Usage

Run your Python application with fdleaky monitoring:

# Run a module
python -m fdleaky your_module

# Run a Python file
python -m fdleaky your_script.py

# Run a package with __main__.py
python -m fdleaky your_package

# Run with uvicorn
poetry run python -m fdleaky uvicorn my_app:app

When a file descriptor remains open longer than the threshold (default 180 seconds), fdleaky will log:

  • The type of resource (file/socket)
  • The stack trace from when it was opened
  • The time it has been open

Development

This project uses poetry for dependency management. To get started:

# Install dependencies
poetry install

# Run tests
poetry run pytest

How it Works

fdleaky works by:

  1. Patching built-in file and socket operations
  2. Tracking all open file descriptors
  3. Monitoring for resources that remain open too long
  4. Providing stack traces to help identify the source of leaks

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

fdleaky-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

fdleaky-0.0.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file fdleaky-0.0.3.tar.gz.

File metadata

  • Download URL: fdleaky-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.8.0-1020-azure

File hashes

Hashes for fdleaky-0.0.3.tar.gz
Algorithm Hash digest
SHA256 57fd930886b061a11de6317eecdf4f4487943e2441b146eb6198ece36fa1c099
MD5 26ae6b43a3b53874bf01a57652176de1
BLAKE2b-256 08cc13b81a798d8b34eb9f799572df36f2bb1eb97373e9af7fc5fff7c086fb46

See more details on using hashes here.

File details

Details for the file fdleaky-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: fdleaky-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.8.0-1020-azure

File hashes

Hashes for fdleaky-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1860644a09f18a52f669fe83f62ce51dd6aae536b7849b1e5e0db2607aa5e5
MD5 f5bb73c4ea1517adcb2a892fb6dc62a0
BLAKE2b-256 6764f7421dcdf9f893ee4e3e5d6f2ed6d8c2eef5d459a4b7a6d959ee97ffba33

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