Pyleak is a Python library inspired by Go's goleak, designed to detect leaked asyncio tasks, threads, and event loop blocking in asynchronous Python applications. The current version is 0.2.0, with frequent minor and patch releases, indicating active development.
pip install pyleakVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `LeakDetector` to identify unawaited or long-running asyncio tasks that are not properly shut down, which pyleak considers a leak. Running this code will raise an `AssertionError` at the end of the `async with LeakDetector():` block.
Update usage from `@no_event_loop_blocking` or `no_event_loop_blocking()` to `async with no_event_loop_blocking():`.
Run your application with `asyncio.run(main(), debug=True)` or set the `PYTHONASYNCIODEBUG` environment variable to `1`.
Ensure all asyncio tasks, threads, and resources are correctly cleaned up or awaited before the `LeakDetector` context exits. For intentional long-lived tasks, consider using `pyleak.set_allow_extra_tasks` for specific test scenarios, though this should be used cautiously.
Upgrade pyleak to version 0.1.16 or newer to benefit from fixes addressing false positives in `CombinedLeakDetector`.
No dependency data recorded yet.