{"id":5104,"library":"aiomonitor","title":"Asyncio Application Monitor and REPL","description":"aiomonitor is a Python library that enhances asyncio applications by providing interactive monitoring and a Python REPL (Read-Eval-Print Loop). It allows developers to inspect the state of running asyncio event loops, tasks, and execute arbitrary asynchronous Python code within the application's context via a telnet interface. Since version 0.6.0, it also includes a web-based UI for task inspection and cancellation. The current version is 0.7.1, with a moderate release cadence.","status":"active","version":"0.7.1","language":"en","source_language":"en","source_url":"https://github.com/aio-libs/aiomonitor","tags":["asyncio","monitoring","repl","debugger","profiling"],"install":[{"cmd":"pip install aiomonitor","lang":"bash","label":"Install aiomonitor"}],"dependencies":[{"reason":"Provides the Python REPL capabilities.","package":"aioconsole"},{"reason":"Used for the optional web-based UI.","package":"aiohttp"},{"reason":"Replaced the deprecated telnet module for robust telnet client support since v0.7.1.","package":"telnetlib3"},{"reason":"Used for defining custom commands for the monitor CLI.","package":"click"}],"imports":[{"symbol":"aiomonitor","correct":"import aiomonitor"},{"symbol":"start_monitor","correct":"from aiomonitor import start_monitor"}],"quickstart":{"code":"import asyncio\nimport aiomonitor\n\nasync def worker():\n    print(\"Worker started...\")\n    try:\n        await asyncio.sleep(100) # Simulate a long-running task\n    except asyncio.CancelledError:\n        print(\"Worker cancelled!\")\n    finally:\n        print(\"Worker finished.\")\n\nasync def main():\n    loop = asyncio.get_running_loop()\n    # start_monitor automatically starts telnet (20101) and web (20102) interfaces\n    with aiomonitor.start_monitor(loop=loop):\n        print(\"aiomonitor started. Connect via telnet localhost 20101 or browser http://localhost:20102\")\n        task = loop.create_task(worker())\n        # Keep the main loop running indefinitely\n        await asyncio.Event().wait()\n        # The task might be cancelled from the monitor, so await it for cleanup\n        await task\n\nif __name__ == \"__main__\":\n    try:\n        asyncio.run(main())\n    except KeyboardInterrupt:\n        print(\"Application gracefully stopped.\")","lang":"python","description":"This quickstart demonstrates how to integrate `aiomonitor` into an asyncio application using its context manager interface. It starts a background worker task and keeps the main loop running. Once executed, you can connect via `telnet localhost 20101` or access the web UI at `http://localhost:20102` to inspect and interact with the running application."},"warnings":[{"fix":"Upgrade your Python environment to 3.9+ or pin aiomonitor to <0.7.1.","message":"Python 3.8 support was dropped in version 0.7.1. aiomonitor now requires Python 3.9 or higher.","severity":"breaking","affected_versions":">=0.7.1"},{"fix":"Use `python -m aiomonitor.cli` or a compatible telnet client when connecting to the monitor.","message":"Since version 0.5.0, connecting to the aiomonitor's REPL requires a proper telnet client (e.g., `telnetlib3` or the included `python -m aiomonitor.cli`). Simple socket-to-console redirectors like `nc` will no longer provide advanced features like auto-completion.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Update your connection commands to use the new default ports: `telnet localhost 20101` and `http://localhost:20102` for the web UI.","message":"The default port numbers for the terminal UI, web UI, and console access changed in version 0.6.0. The telnet interface moved from 50101 to 20101 and the web UI from 50201 to 20102.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Use `loop = asyncio.get_running_loop()` to explicitly get the current loop, or consider if the `loop` argument to `start_monitor` can be omitted if a running loop is guaranteed.","message":"The `loop` argument for `asyncio.get_event_loop()` is deprecated in Python 3.10+ and should be replaced with `asyncio.get_running_loop()` if an event loop is already running. While `aiomonitor.start_monitor` still accepts a `loop` argument, it's often preferred to rely on `asyncio.get_running_loop()` implicitly within `asyncio.run()` contexts or pass `None` to `start_monitor` if a loop is already set.","severity":"deprecated","affected_versions":"All versions, especially with Python >=3.10"},{"fix":"Check for official recommendations regarding Windows compatibility or consider alternative deployment environments if `reuse_port` conflicts arise.","message":"Users on Windows might encounter issues with `reuse_port` not being supported by the socket module when using `aiomonitor`, particularly with alternative event loops like `winloop`.","severity":"gotcha","affected_versions":"All versions on Windows"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}