{"id":18847274,"url":"https://github.com/nhoad/aiomanhole","last_synced_at":"2025-04-14T08:09:33.528Z","repository":{"id":44804026,"uuid":"20968996","full_name":"nhoad/aiomanhole","owner":"nhoad","description":"Manhole for accessing asyncio applications","archived":false,"fork":false,"pushed_at":"2022-01-23T15:48:17.000Z","size":35,"stargazers_count":32,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T08:09:27.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nhoad.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-18T16:14:14.000Z","updated_at":"2024-09-24T01:22:53.000Z","dependencies_parsed_at":"2022-09-26T19:01:52.261Z","dependency_job_id":null,"html_url":"https://github.com/nhoad/aiomanhole","commit_stats":null,"previous_names":["nathan-hoad/aiomanhole"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhoad%2Faiomanhole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhoad%2Faiomanhole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhoad%2Faiomanhole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhoad%2Faiomanhole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhoad","download_url":"https://codeload.github.com/nhoad/aiomanhole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843856,"owners_count":21170492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T03:07:23.846Z","updated_at":"2025-04-14T08:09:33.498Z","avatar_url":"https://github.com/nhoad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"aiomanhole\n==========\n\nManhole for accessing asyncio applications. This is useful for debugging\napplication state in situations where you have access to the process, but need\nto access internal application state.\n\nAdding a manhole to your application is simple::\n\n    from aiomanhole import start_manhole\n\n    start_manhole(namespace={\n        'gizmo': application_state_gizmo,\n        'whatsit': application_state_whatsit,\n    })\n\nQuick example, in one shell, run this::\n\n    $ python -m aiomanhole\n\nIn a secondary shell, run this::\n\n    $ nc -U /var/tmp/testing.manhole\n    Well this is neat\n    \u003e\u003e\u003e f = 5 + 5\n    \u003e\u003e\u003e f\n    10\n    \u003e\u003e\u003e import os\n    \u003e\u003e\u003e os.getpid()\n    4238\n    \u003e\u003e\u003e import sys\n    \u003e\u003e\u003e sys.exit(0)\n\n\nAnd you'll see the manhole you started has exited.\n\nThe package provides both a threaded and non-threaded interpreter, and allows\nyou to share the namespace between clients if you want.\n\n\nI'm getting \"Address is already in use\" when I start! Help!\n===========================================================\n\nUnlike regular TCP/UDP sockets, UNIX domain sockets are entries in the\nfilesystem. When your process shuts down, the UNIX socket that is created is\nnot cleaned up. What this means is that when your application starts up again,\nit will attempt to bind a UNIX socket to that path again and fail, as it is\nalready present (it's \"already in use\").\n\nThe standard approach to working with UNIX sockets is to delete them before you\ntry to bind to it again, for example::\n\n    import os\n    try:\n        os.unlink('/path/to/my.manhole')\n    except FileNotFoundError:\n        pass\n    start_manhole('/path/to/my.manhole')\n\n\nYou may be tempted to try and clean up the socket on shutdown, but don't. What\nif your application crashes? What if your computer loses power? There are lots\nof things that can go wrong, and hoping the previous run was successful, while\nadmirably positive, is not something you can do.\n\n\nCan I specify what is available in the manhole?\n===============================================\nYes! When you call `start_manhole`, just pass along a dictionary of what you\nwant to provide as the namespace parameter::\n\n    from aiomanhole import start_manhole\n\n    start_manhole(namespace={\n        'gizmo': application_state_gizmo,\n        'whatsit': application_state_whatsit,\n        'None': 5,  # don't do this though\n    })\n\n\nWhen should I use threaded=True?\n================================\n\nSpecifying threaded=True means that statements in the interactive session are\nexecuted in a thread, as opposed to executing them in the event loop.\n\nSay for example you did this in a non-threaded interactive session::\n\n    \u003e\u003e\u003e while True:\n    ...  pass\n    ...\n\nYou've just broken your application! You can't abort that without restarting\nthe application. If however you ran that in a threaded application, you'd\n'only' have a thread trashing the CPU, slowing down your application, as\nopposed to making it totally unresponsive.\n\nBy default, a threaded interpreter will time out commands after 5 seconds,\nthough this is configurable. Not that this will **not** kill the thread, but\nallow you to keep running commands.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhoad%2Faiomanhole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhoad%2Faiomanhole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhoad%2Faiomanhole/lists"}