{"library":"pyleak","title":"Pyleak","description":"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.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install pyleak"],"cli":null},"imports":["from pyleak import LeakDetector","from pyleak import no_event_loop_blocking","from pyleak import CombinedLeakDetector"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import asyncio\nfrom pyleak import LeakDetector\n\nasync def create_leak():\n    # A task that runs forever, simulating a leak\n    async def forever_task():\n        while True:\n            await asyncio.sleep(100)\n    asyncio.create_task(forever_task())\n\nasync def main():\n    async with LeakDetector():\n        await create_leak()\n        print(\"This will run, but a leak was created.\")\n    # LeakDetector exits, will raise AssertionError if leaks are found\n    print(\"LeakDetector exited, no assertion was raised (this line won't be reached if a leak is present).\")\n\nif __name__ == \"__main__\":\n    # To see the AssertionError from the leak:\n    # asyncio.run(main())\n    \n    # To avoid the assertion for demonstration:\n    try:\n        asyncio.run(main())\n    except AssertionError as e:\n        print(f\"Caught expected leak: {e}\")","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"0.2.0","pypi_latest":"0.2.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.7,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"20.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyleak","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"18M"}]}}