aio asyncio框架的Manhole服务器
项目描述
为aio asyncio框架提供的Manhole服务器
构建状态
安装
需要python >= 3.4
使用以下方法安装
pip install aio.manhole.server
快速开始 - Manhole服务器
将以下内容保存到文件“manhole.conf”中
[server/my_manhole_server]
factory = aio.manhole.server.factory
port = 7373
使用aio run命令运行
aio run -c manhole.conf
现在您应该能够telnet到正在运行的服务器,端口号为7373
aio.manhole.server使用方法
配置
让我们创建一个manhole配置
>>> config = """ ... [aio] ... log_level = ERROR ... ... [server/server_name] ... factory = aio.manhole.server.factory ... port = 7373 ... ... """
>>> import sys >>> import io >>> import aiomanhole
>>> import aio.testing >>> import aio.app >>> from aio.app.runner import runner
当我们运行manhole服务器时,它可以通过“server_name”从aio.app.servers访问
>>> @aio.testing.run_forever(sleep=1) ... def run_manhole_server(config): ... yield from runner(['run'], config_string=config) ... ... def call_manhole(): ... print(aio.app.servers["server_name"]) ... aio.app.clear() ... ... return call_manhole
>>> run_manhole_server(config) <Server sockets=[<socket.socket ...laddr=('0.0.0.0', 7373)...>
让我们尝试调用manhole服务器
>>> import asyncio >>> import telnetlib3
>>> @aio.testing.run_forever(sleep=1) ... def run_manhole_server(config): ... yield from runner(['run'], config_string=config) ... ... class TestTelnetClient(telnetlib3.TelnetClient): ... ... def data_received(self, data): ... print(data) ... ... def call_manhole(): ... loop = asyncio.get_event_loop() ... transport, protocol = yield from loop.create_connection( ... TestTelnetClient, "127.0.0.1", 7373) ... aio.app.clear() ... ... return call_manhole
>>> run_manhole_server(config) b'hello...\n>>> '
项目详情
关闭
aio.manhole.server-0.0.2.tar.gz的散列
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0c85edc251a759441c93ba23a4b38dc4b96e954991d783ef2b06c36c517c35a3 |
|
MD5 | a150a965507597ca53fede997120d9cf |
|
BLAKE2b-256 | bf9197150fee8d29b027dac8abf5f6f97af7cf6c514801ff0388b0c569420a4e |