Skip to main content

Asynchronous console and interfaces for asyncio

Project description

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

Requirements

  • Python >= 3.6

Installation

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

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

$ 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)
---
>>> await asyncio.sleep(1, result=3)
# Wait one second...
3
>>>

Documentation

Find more examples in the documentation and the example directory.

Limitations

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:

Contact

Vincent Michel: vxgmichel@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioconsole-0.6.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

aioconsole-0.6.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file aioconsole-0.6.0.tar.gz.

File metadata

  • Download URL: aioconsole-0.6.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aioconsole-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ec08ca307bfc1d81ccc156d00b8c7eae510fe03a91a48d5aed95f50915b3e9d6
MD5 866936c53fae1a36ea265e238c770f38
BLAKE2b-256 56c1f5305eb0c3ece3df90c5aff4fd8c9dbb65b0c44058ae20a1228523ed0539

See more details on using hashes here.

Provenance

File details

Details for the file aioconsole-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: aioconsole-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aioconsole-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c3f29116d209ffe21c0ef2e5846882891819bd714d630e4350a4b19a61aac0a
MD5 739860342251921648f8fb283054582d
BLAKE2b-256 078ad83c64f1a48d14928147d391b67af920845a4bed20d5fee142fdd36881c5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page