--- id: pyleak version: "0.2.0" license: unclear license_treatment: unclear maintenance: aging --- # pyleak — Detect leaked asyncio tasks, threads, and event loop blocking in Python. Inspired by Go's goleak License: unclear · Maintenance: aging · Downloads: 562.5K/mo ## What it is and what it does pyleak is a testing and debugging tool that catches resource leaks in Python async code. It provides three main detectors—no_task_leaks, no_thread_leaks, and no_event_loop_blocking—each usable as a context manager or decorator. When a leak or blocking event is detected, the tool reports it with detailed stack traces showing where the resource was created and where it is currently executing. You configure the response via an action parameter: warn (default, issues ResourceWarning), log (writes to logger), cancel (for tasks only), or raise (throws an exception). The package is inspired by Go's goleak and targets developers writing asyncio-heavy applications who need to catch unintended resource leaks during testing. It depends on exceptiongroup and sniffio, both lightweight libraries. The tool supports name filtering by exact match or regex pattern for tasks and threads, and optional creation-stack tracking (via monkey-patching) for deeper debugging. It requires Python 3.9 or later. Use it for: - Detect unintended asyncio tasks left running after a test or function completes - Catch threads spawned but never properly joined in sync code paths - Identify blocking calls (e.g., time.sleep) that freeze the event loop during async execution - Validate cleanup in async context managers and fixture teardown - Debug resource leaks in long-running async services before deployment ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Detects leaked asyncio tasks, threads, and event loop blocking in Python code using context managers or decorators, reporting violations with stack traces. Yes, if you write asyncio or threaded code and want automated leak detection during testing. The low install friction and clear API make it straightforward to add to test suites. However, verify the license terms first (currently unclear in the metadata), and note that the project is aging—last release was 197 days ago. Not suitable for production monitoring; use it as a development and testing tool. ## Install pip install pyleak uv add pyleak poetry add pyleak ## Installing pyleak Before you install: Low install friction with only two lightweight runtime dependencies (exceptiongroup, sniffio). Maintenance status is aging—last release was 197 days ago, though the repository remains active with 403 stars. License in practice: License status is unclear; no SPDX identifier or raw license text is available in the package metadata. Verify the actual license before use in proprietary or restricted-license projects. Quickstart: pip install pyleak import asyncio from pyleak import no_task_leaks async def main(): async with no_task_leaks(): asyncio.create_task(asyncio.sleep(10)) await asyncio.sleep(0.1) asyncio.run(main()) Requires Python 3.9 or later. Event loop blocking detection only works in async context; thread detection only in sync context. Verify before relying: - Whether the package is suitable for production use or primarily for testing and development - Actual license terms and any attribution or usage restrictions - Performance overhead of leak detection in real-world async codebases ## Package facts - License: not declared (unclear) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 562.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio task leak detection, thread leak detection python, event loop blocking detector, resource leak testing, asyncio testing tools, asyncio-testing, resource-leak-detection, debugging [View on SkillFed](https://skillfed.io/packages/pyleak) · [View on PyPI](https://pypi.org/project/pyleak/)