---
title: "aioconsole | pypx"
description: "Asynchronous console and interfaces for asyncio"
canonical_url: "https://pypx.app/packages/aioconsole"
meta:
  "og:description": "Asynchronous console and interfaces for asyncio"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_aioconsole%2Cversion_0.9.0%2Csummary_Asynchronous%2Bconsole%2Band%2Binterfaces%2Bfor%2Basyncio%2Clicense_GPL-3.0-or-later%2Cp_Ii9wYWNrYWdlcy9haW9jb25zb2xlIg%2Cs_Pu-yYkx75xhDAYBG.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "aioconsole 0.9.0"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_aioconsole%2Cversion_0.9.0%2Csummary_Asynchronous%2Bconsole%2Band%2Binterfaces%2Bfor%2Basyncio%2Clicense_GPL-3.0-or-later%2Cp_Ii9wYWNrYWdlcy9haW9jb25zb2xlIg%2Cs_Pu-yYkx75xhDAYBG.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **aioconsole**

v0.9.0

Asynchronous console and interfaces for asyncio

31 KB Python 3.10.3+ py3-none-anyGPL-3.0-or-later

[** Diff **](https://pypx.app/packages/aioconsole/diff)

`$ uv add aioconsole`

# aioconsole

Asynchronous console and interfaces for asyncio

aioconsole\_ provides:

- asynchronous equivalents to `input`\_, `print`\_, `exec`\_ and `code.interact`\_
- an interactive loop running the asynchronous python console
- a way to customize and run command line interface using `argparse`\_
- `stream`\_ support to serve interfaces instead of using standard streams
- the apython script to access asyncio code at runtime without modifying the sources

⚠️ Limitations --------------

#### Better alternative to aioconsole.ainput()

A common use case for aioconsole is the async alternative to the builtin `input`\_ function. However, aioconsole\_ was written in 2015 and since then the powerful prompt-toolkit\_ library has gained better asyncio support. The recommended way to [prompt in an asyncio application](https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#prompt-in-an-asyncio-application) is now to use the `prompt-toolkit`\_ library:

```python3
from prompt_toolkit import PromptSession
from prompt_toolkit.patch_stdout import patch_stdout

async def my_coroutine():
   session = PromptSession()
   while True:
      with patch_stdout():
            result = await session.prompt_async("Say something: ")
      print(f"You said: {result}")
```

#### Better python consoles with async support

The 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:

- [Embedding a ptpython console in an asyncio program](https://github.com/prompt-toolkit/ptpython/blob/master/examples/asyncio-python-embed.py)
- [Using the await syntax in an IPython console](https://ipython.readthedocs.io/en/stable/whatsnew/version7.html#autowait-asynchronous-repl)

## Requirements

- Python \\>= 3.10.3

## Installation

aioconsole\_ is available on PyPI\_ and GitHub\_. Both of the following commands install the aioconsole package and the apython script.

```console
$ pip3 install aioconsole   # from PyPI
$ python3 setup.py install  # or from the sources
$ apython -h
usage: apython [-h] [--serve [HOST:] PORT] [--no-readline]
               [--banner BANNER] [--locals LOCALS]
               [-m MODULE | FILE] ...

Run the given python file or module with a modified asyncio policy replacing
the default event loop with an interactive loop. If no argument is given, it
simply runs an asynchronous python console.

positional arguments:
  FILE                  python file to run
  ARGS                  extra arguments

optional arguments:
  -h, --help            show this help message and exit
  --serve [HOST:] PORT, -s [HOST:] PORT
                        serve a console on the given interface instead
  --no-readline         force readline disabling
  --banner BANNER       provide a custom banner
  --locals LOCALS       provide custom locals as a dictionary
  -m MODULE             run a python module
```

## Simple usage

The following example demonstrates the use of await inside the console:

```console
$ apython
Python 3.5.0 (default, Sep 7 2015, 14:12:03)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
---
This console is running in an asyncio event loop.
It allows you to wait for coroutines using the 'await' syntax.
Try: await asyncio.sleep(1, result=3, loop=loop)
---
```

```python3
>>> await asyncio.sleep(1, result=3)
# Wait one second...
3
>>>
```

## Documentation

Find more examples in the documentation\_ and the `example directory`\_.

## Contact

Vincent Michel: vxgmichel@gmail.com

## **Details **

<dl>

<dt>Version</dt>
<dd>0.9.0</dd>

<dt>License</dt>
<dd>GPL-3.0-or-later</dd>

<dt>Python</dt>
<dd>&gt;=3.10.3</dd>

<dt>Maintainer</dt>
<dd>Vincent Michel &lt;vxgmichel@gmail.com&gt;</dd></dl>

## **Links**

- [Homepage](https://github.com/vxgmichel/aioconsole)
- [View on PyPI](https://pypi.org/project/aioconsole/)

## **Release Cadence **

**1**

releases in the past year

avg 113 days between releases

## **Maintainers **

- Vincent Michel · [vxgmichel@gmail.com](mailto:vxgmichel@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/aioconsole#webpage","@type":"WebPage","description":"Asynchronous console and interfaces for asyncio","name":"aioconsole","url":"https://pypx.app/packages/aioconsole","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/aioconsole"]}]},{"@id":"https://pypx.app/packages/aioconsole#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Asynchronous console and interfaces for asyncio","license":"GPL-3.0-or-later","name":"aioconsole","softwareVersion":"0.9.0"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
