{"id":23537651,"url":"https://github.com/loic-simon/asyncode","last_synced_at":"2025-08-12T13:45:07.928Z","repository":{"id":55742599,"uuid":"318912532","full_name":"loic-simon/asyncode","owner":"loic-simon","description":"Emulating Python's interactive interpreter in asynchronous contexts","archived":false,"fork":false,"pushed_at":"2020-12-12T18:00:29.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-26T03:17:09.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loic-simon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-12-05T23:46:56.000Z","updated_at":"2021-12-31T17:13:44.000Z","dependencies_parsed_at":"2022-08-15T06:40:46.329Z","dependency_job_id":null,"html_url":"https://github.com/loic-simon/asyncode","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loic-simon%2Fasyncode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loic-simon%2Fasyncode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loic-simon%2Fasyncode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loic-simon%2Fasyncode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loic-simon","download_url":"https://codeload.github.com/loic-simon/asyncode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239250611,"owners_count":19607495,"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-12-26T03:17:10.176Z","updated_at":"2025-02-17T07:26:50.456Z","avatar_url":"https://github.com/loic-simon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asyncode\n[![PyPI](https://img.shields.io/pypi/v/asyncode)](https://pypi.org/project/asyncode)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/asyncode)](https://pypi.org/project/asyncode)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/asyncode)](https://pypi.org/project/asyncode)\n[![Read the Docs](https://img.shields.io/readthedocs/asyncode)](https://asyncode.readthedocs.io)\n[![Travis CI](https://img.shields.io/travis/loic-simon/asyncode)](https://travis-ci.org/github/loic-simon/asyncode)\n\nPython package for emulating Python's interactive interpreter in asynchronous contexts.\n\n\n## Installation\n\nUse the package manager [pip](https://pypi.org/project/pip) to install asyncode:\n```bash\npip install asyncode\n```\n\n### Dependencies\n\n* Python **≥ 3.5** *(no CI for Python \u003c 3.8)*\n\n\n\n## Usage\n\nThis package's external API consists in two classes, **`AsyncInteractiveInterpreter`** and **`AsyncInteractiveConsole`**, which subclass respectively [`code.InteractiveInterpreter`](https://docs.python.org/3/library/code.html#interactive-interpreter-objects) and [`code.InteractiveConsole`](https://docs.python.org/3/library/code.html#interactive-console-objects).\n\nThese classes are meant to be used in **already running asynchronous contexts**. Minimal useful code will need to subclass provided classes to implement specific functions:\n\n```py\nimport asyncode\n\nclass MyAsyncConsole(asyncode.AsyncInteractiveConsole):\n    \"\"\"AsyncInteractiveConsole adapted to running environment\"\"\"\n\n    async def write(self, data):\n        \"\"\"Use specific function\"\"\"\n        await some_output_coroutine(data)\n\n    async def raw_input(self, prompt=\"\"):\n        \"\"\"Use specific functions\"\"\"\n        if prompt:\n            await some_output_coroutine(prompt)\n\n        data = await some_input_coroutine()\n        return data\n\n\nasync def run_interpreter():\n    \"\"\"Run an interactive Python interpreter\"\"\"\n    console = MyAsyncConsole()\n    try:\n        await console.interact()\n    except SystemExit:\n        # Do not exit the whole program when sending \"exit()\" or \"quit()\"\n        await some_output_coroutine(\"Bye!\")\n```\n\nRead [the docs](https://asyncode.readthedocs.io) for more informations.\n\n\n\n## Contributing\n\nPull requests are welcome. Do not hesitate to get in touch with me (see below) for any question or suggestion about this project!\n\n\n\n## License\n\nThis work is shared under [the MIT license](LICENSE).\n\n© 2020 Loïc Simon ([loic.simon@espci.org](mailto:loic.simon@espci.org))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floic-simon%2Fasyncode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floic-simon%2Fasyncode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floic-simon%2Fasyncode/lists"}