异步控制器和接口
aioconsole的Python项目详细描述
异步控制台和异步接口
aioconsole提供:
- 异步等价于input、print、exec和code.interact
- 运行异步python控制台的交互式循环
- 使用argparse 自定义和运行命令行界面的方法
- stream支持服务接口而不是使用标准流
- 在运行时访问异步代码而不修改源的apython脚本
要求
- python=3.4
安装
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) ---
>>>awaitasyncio.sleep(1,result=3)# Wait one second...3>>>
文件
在documentation和example directory中查找更多示例。
联系人
文森特·米歇尔:vxgmichel@gmail.com