异步控制台和asyncio接口
项目描述
异步控制台和asyncio接口
aioconsole 提供
异步等价于 input、print、exec 和 code.interact
运行异步Python控制台的交互循环
使用 argparse 自定义和运行命令行界面
通过 stream 支持而不是使用标准流来提供接口
apython 脚本,在运行时访问asyncio代码而不修改源代码
要求
Python >= 3.8
安装
aioconsole 可在 PyPI 和 GitHub 上找到。以下两个命令都安装了 aioconsole 软件包和 apython 脚本。
$ 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
简单用法
以下示例演示了在控制台内使用 await
$ 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
>>>
文档
限制
与IPython或ptpython等现代控制台相比,由aioconsole提供的Python控制台功能相当有限。幸运的是,这些项目在多年的发展中获得了更大的asyncio支持。特别是,以下用例与aioconsole功能重叠:
联系
Vincent Michel: vxgmichel@gmail.com
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
aioconsole-0.8.0.tar.gz (60.7 kB 查看哈希值)
构建分布
aioconsole-0.8.0-py3-none-any.whl (43.3 kB 查看哈希值)
关闭
aioconsole-0.8.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 64c93c17ef878fc68b4b379b9ed7fbb96c6fbc1b4e9a8378f9f899299ebdd37f |
|
MD5 | a644cd04d15488d61fc18c1d3b9816c5 |
|
BLAKE2b-256 | 89dc523222a45a83e69319724362db1664185970bca20c7d643c9261cfcddfb1 |
关闭
aioconsole-0.8.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a8f7d3049df0518f4e50de7d94c082097785b6a675befd62e8da5539d3d2f8ca |
|
MD5 | 5d781583770f8d684dfaa08d535696b8 |
|
BLAKE2b-256 | c44d4bd0c11f58dfdd2155f82f461d02646e9ab759d902c4a62c935e60cc5ea8 |