{"id":7908,"library":"aiodebug","title":"AioDebug","description":"AioDebug is a lightweight Python library designed for monitoring and testing `asyncio` programs. It provides features like logging slow callbacks, tracking event loop lags, and dumping stack traces for unresponsive loops, intended for always-on use in production environments. The current version is 2.3.0, released on January 4, 2022. It has an infrequent release cadence.","status":"active","version":"2.3.0","language":"python","source_language":"en","source_url":"https://gitlab.com/quantlane/libs/aiodebug","tags":["asyncio","debugging","monitoring","performance"],"install":[{"cmd":"pip install aiodebug","lang":"bash","label":"pip"},{"cmd":"poetry add aiodebug","lang":"bash","label":"Poetry"}],"dependencies":[{"reason":"Used for logging if installed, otherwise defaults to the standard logging module.","package":"logwood","optional":true}],"imports":[{"symbol":"log_slow_callbacks","correct":"import aiodebug.log_slow_callbacks"},{"symbol":"monitor_loop_lag","correct":"import aiodebug.monitor_loop_lag"},{"symbol":"hang_inspection","correct":"import aiodebug.hang_inspection"}],"quickstart":{"code":"import asyncio\nimport time\nimport logging\nimport aiodebug.log_slow_callbacks\n\nlogging.basicConfig(level=logging.WARNING)\n\nasync def slow_task():\n    print(\"Starting slow task...\")\n    # Simulate a blocking I/O operation or CPU-bound task\n    time.sleep(0.1) \n    print(\"Slow task finished.\")\n\nasync def main():\n    print(\"Enabling slow callback logging...\")\n    aiodebug.log_slow_callbacks.enable(0.05) # Log callbacks slower than 0.05 seconds\n    print(\"Running main task...\")\n    await asyncio.sleep(0.01) # Small non-blocking sleep\n    await slow_task()\n    print(\"Main task finished.\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to use `aiodebug.log_slow_callbacks` to identify and log `asyncio` callbacks that block the event loop for longer than a specified duration. The `slow_task` simulates a blocking operation (using `time.sleep`) which `aiodebug` will detect and report."},"warnings":[{"fix":"Always check the project's PyPI page or GitHub README for the most current repository link.","message":"The official GitHub repository at `qntln/aiodebug` states that the project has moved to `gitlab.com/quantlane/libs/aiodebug`. Users looking for the most up-to-date source code, issues, or contributions should refer to the GitLab instance.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand that `aiodebug` targets event loop blocking. For overall long-running *asynchronous* tasks, traditional profiling tools or custom instrumentation might be more appropriate.","message":"`aiodebug` primarily identifies *blocking* calls that prevent the `asyncio` event loop from progressing. It does not report on `asyncio`-friendly tasks that simply have a long overall execution time but yield correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Structure your `asyncio` code to encapsulate potentially blocking operations within their own distinct `async` functions or `Task`s where possible, and avoid direct blocking calls within critical path coroutines, or use `asyncio.to_thread` for CPU-bound work.","message":"When using `aiodebug.log_slow_callbacks`, if a parent coroutine directly `await`s a blocking function, `aiodebug` might report the parent coroutine as slow, rather than pinpointing the exact blocking sub-task. This can be misleading.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'2.3.0':46 '2022':51 '4':50 'aiodebug':1,2 'alway':36 'always-on':35 'asyncio':13,58 'cadenc':57 'callback':21 'current':43 'debug':59 'design':8 'dump':27 'environ':41 'event':23 'featur':17 'infrequ':55 'intend':33 'januari':49 'lag':25 'librari':7 'lightweight':5 'like':18 'log':19 'loop':24,32 'monitor':10,60 'perform':61 'product':40 'program':14 'provid':16 'python':6 'releas':47,56 'slow':20 'stack':28 'test':12 'trace':29 'track':22 'unrespons':31 'use':38 'version':44","created_at":"2026-04-16T16:58:52.427754+00:00","updated_at":"2026-04-16T16:58:52.427754+00:00","problems":[{"fix":"Review the indicated coroutine (`some_function`) and identify the blocking operation. Consider using `asyncio.to_thread()` for CPU-bound tasks, ensuring I/O operations are truly asynchronous, or breaking down long synchronous operations.","cause":"A coroutine or callback blocked the `asyncio` event loop for longer than the threshold set in `aiodebug.log_slow_callbacks.enable()`.","error":"WARNING: Executing <Task pending coro=<some_function() running at ...> ...> took X.YYY seconds"},{"fix":"Import the specific submodule that contains the desired feature, for example, `import aiodebug.log_slow_callbacks` to use `aiodebug.log_slow_callbacks.enable()`.","cause":"Attempting to access a `aiodebug` feature directly from the `aiodebug` top-level module (e.g., `aiodebug.enable_slow_callbacks`). The library's functionalities are organized into submodules.","error":"AttributeError: module 'aiodebug' has no attribute 'some_feature_name'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.3.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://gitlab.com/quantlane/libs/aiodebug","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/aiodebug/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}