Skip to main content

Manhole server for the aio asyncio framework

Project description

Manhole server for the aio asyncio framework

Build status

https://travis-ci.org/phlax/aio.manhole.server.svg?branch=master

Installation

Requires python >= 3.4

Install with:

pip install aio.manhole.server

Quick start - Manhole server

Save the following into a file “manhole.conf”

[server/my_manhole_server]
factory = aio.manhole.server.factory
port = 7373

Run with the aio run command

aio run -c manhole.conf

You should now be able to telnet into the running server on port 7373

aio.manhole.server usage

Configuration

Lets create a manhole configuration

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

When we run the manhole server, its accessible as “server_name” from 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)...>

Lets try calling the manhole server

>>> 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>>> '

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

aio.manhole.server-0.0.1.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file aio.manhole.server-0.0.1.tar.gz.

File metadata

File hashes

Hashes for aio.manhole.server-0.0.1.tar.gz
Algorithm Hash digest
SHA256 521575f7e30719be8bf2b951f8e5adb5a1d4d5b63839fb7c97e87d5c3b4e4e5c
MD5 c9ca50fe400d849555a8d3f549209e9a
BLAKE2b-256 792c0e0d197f6474e5645142d96df1b5f7fcf896a6354904e3488eaf06c3dd4d

See more details on using hashes here.

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