{"id":13648314,"url":"https://github.com/vxgmichel/aioconsole","last_synced_at":"2025-05-14T19:10:19.518Z","repository":{"id":41543575,"uuid":"44499555","full_name":"vxgmichel/aioconsole","owner":"vxgmichel","description":"Asynchronous console and interfaces for asyncio","archived":false,"fork":false,"pushed_at":"2024-11-19T21:01:52.000Z","size":279,"stargazers_count":471,"open_issues_count":10,"forks_count":40,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-04T20:02:36.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://aioconsole.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vxgmichel.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-18T22:39:53.000Z","updated_at":"2025-04-25T17:27:03.000Z","dependencies_parsed_at":"2023-12-09T18:26:01.149Z","dependency_job_id":"9359a576-42c6-44d6-a447-1d01438b4b68","html_url":"https://github.com/vxgmichel/aioconsole","commit_stats":{"total_commits":323,"total_committers":19,"mean_commits":17.0,"dds":0.6501547987616099,"last_synced_commit":"c088cfddc5db45297ed7fdff4b1e931d710596b5"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxgmichel%2Faioconsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxgmichel%2Faioconsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxgmichel%2Faioconsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxgmichel%2Faioconsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vxgmichel","download_url":"https://codeload.github.com/vxgmichel/aioconsole/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655954,"owners_count":21943081,"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-08-02T01:04:08.152Z","updated_at":"2025-05-14T19:10:17.574Z","avatar_url":"https://github.com/vxgmichel.png","language":"Python","funding_links":[],"categories":["HarmonyOS","Python"],"sub_categories":["Windows Manager"],"readme":"aioconsole\n==========\n\n|docs-badge| |cov-badge| |ci-badge| |version-badge| |pyversion-badge|\n\n\nAsynchronous console and interfaces for asyncio\n\naioconsole_ provides:\n\n* asynchronous equivalents to `input`_, `print`_, `exec`_ and `code.interact`_\n* an interactive loop running the asynchronous python console\n* a way to customize and run command line interface using `argparse`_\n* `stream`_ support to serve interfaces instead of using standard streams\n* the ``apython`` script to access asyncio code at runtime without modifying the sources\n\n⚠️ Limitations\n--------------\n\nBetter alternative to ``aioconsole.ainput()``\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nA common use case for aioconsole is the async alternative to the builtin `input`_ function.\nHowever, aioconsole_ was written in 2015 and since then the powerful prompt-toolkit_ library has gained better asyncio support.\nThe recommended way to `prompt in an asyncio application \u003chttps://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#prompt-in-an-asyncio-application\u003e`_ is now to use the `prompt-toolkit`_ library:\n\n.. code:: python3\n\n   from prompt_toolkit import PromptSession\n   from prompt_toolkit.patch_stdout import patch_stdout\n\n   async def my_coroutine():\n      session = PromptSession()\n      while True:\n         with patch_stdout():\n               result = await session.prompt_async(\"Say something: \")\n         print(f\"You said: {result}\")\n\n\nBetter python consoles with async support\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe python console exposed by `aioconsole`_ is quite limited compared to modern consoles such as `IPython`_ or `ptpython`_. Luckily, those projects gained greater asyncio support over the years. In particular, the following use cases overlap with `aioconsole`_ capabilities:\n\n- `Embedding a ptpython console in an asyncio program \u003chttps://github.com/prompt-toolkit/ptpython/blob/master/examples/asyncio-python-embed.py\u003e`_\n- `Using the await syntax in an IPython console \u003chttps://ipython.readthedocs.io/en/stable/whatsnew/version7.html#autowait-asynchronous-repl\u003e`_\n\n\nRequirements\n------------\n\n*  Python \\\u003e= 3.8\n\n\nInstallation\n------------\n\naioconsole_ is available on PyPI_ and GitHub_.\nBoth of the following commands install the ``aioconsole`` package\nand the ``apython`` script.\n\n.. code:: console\n\n    $ pip3 install aioconsole   # from PyPI\n    $ python3 setup.py install  # or from the sources\n    $ apython -h\n    usage: apython [-h] [--serve [HOST:] PORT] [--no-readline]\n                   [--banner BANNER] [--locals LOCALS]\n                   [-m MODULE | FILE] ...\n\n    Run the given python file or module with a modified asyncio policy replacing\n    the default event loop with an interactive loop. If no argument is given, it\n    simply runs an asynchronous python console.\n\n    positional arguments:\n      FILE                  python file to run\n      ARGS                  extra arguments\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      --serve [HOST:] PORT, -s [HOST:] PORT\n                            serve a console on the given interface instead\n      --no-readline         force readline disabling\n      --banner BANNER       provide a custom banner\n      --locals LOCALS       provide custom locals as a dictionary\n      -m MODULE             run a python module\n\n\n\nSimple usage\n------------\n\nThe following example demonstrates the use of ``await`` inside the console:\n\n.. code:: console\n\n    $ apython\n    Python 3.5.0 (default, Sep 7 2015, 14:12:03)\n    [GCC 4.8.4] on linux\n    Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n    ---\n    This console is running in an asyncio event loop.\n    It allows you to wait for coroutines using the 'await' syntax.\n    Try: await asyncio.sleep(1, result=3, loop=loop)\n    ---\n\n.. code:: python3\n\n    \u003e\u003e\u003e await asyncio.sleep(1, result=3)\n    # Wait one second...\n    3\n    \u003e\u003e\u003e\n\n\nDocumentation\n-------------\n\nFind more examples in the documentation_ and the `example directory`_.\n\n\nContact\n-------\n\nVincent Michel: vxgmichel@gmail.com\n\n.. _aioconsole: https://pypi.python.org/pypi/aioconsole\n.. _GitHub: https://github.com/vxgmichel/aioconsole\n.. _input: https://docs.python.org/3/library/functions.html#input\n.. _print: https://docs.python.org/3/library/functions.html#print\n.. _exec: https://docs.python.org/3/library/functions.html#exec\n.. _code.interact: https://docs.python.org/3/library/code.html#code.interact\n.. _argparse: https://docs.python.org/dev/library/argparse.html\n.. _stream: https://docs.python.org/3/library/asyncio-stream.html\n.. _example directory: https://github.com/vxgmichel/aioconsole/blob/main/example\n.. _documentation: http://aioconsole.readthedocs.io/\n.. _PyPI: aioconsole_\n.. _IPython: https://ipython.readthedocs.io\n.. _ptpython: https://github.com/prompt-toolkit/ptpython\n.. _prompt-toolkit: https://python-prompt-toolkit.readthedocs.io\n\n.. |docs-badge| image:: https://readthedocs.org/projects/aioconsole/badge/?version=latest\n   :target: http://aioconsole.readthedocs.io/\n   :alt:\n\n.. |ci-badge| image:: https://github.com/vxgmichel/aioconsole/workflows/CI/badge.svg\n   :target: https://github.com/vxgmichel/aioconsole/actions?query=branch%3Amain\n   :alt:\n\n.. |cov-badge| image:: https://codecov.io/gh/vxgmichel/aioconsole/branch/main/graph/badge.svg\n   :target: https://codecov.io/gh/vxgmichel/aioconsole\n   :alt:\n\n.. |version-badge| image:: https://img.shields.io/pypi/v/aioconsole.svg\n   :target: https://pypi.python.org/pypi/aioconsole\n   :alt:\n\n.. |pyversion-badge| image:: https://img.shields.io/pypi/pyversions/aioconsole.svg\n   :target: https://pypi.python.org/pypi/aioconsole\n   :alt:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvxgmichel%2Faioconsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvxgmichel%2Faioconsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvxgmichel%2Faioconsole/lists"}