async-multiplexer-0.1.0
توضیحات
Asyncio TCP Multiplexer
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | async-multiplexer-0.1.0 |
| نام | async-multiplexer |
| نسخه کتابخانه | 0.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Aratz M. Lasa |
| ایمیل نویسنده | aratz.m.lasa@gmail.com |
| آدرس صفحه اصلی | https://github.com/aratz-lasa/async-multiplexer |
| آدرس اینترنتی | https://pypi.org/project/async-multiplexer/ |
| مجوز | - |
# async_multiplexer
[](https://badge.fury.io/py/async-multiplexer)
[](https://www.python.org/downloads/release/python-380/)
[](https://travis-ci.com/aratz-lasa/async-multiplexer)
[](https://codecov.io/gh/aratz-lasa/async-multiplexer)
[](https://www.python.org/dev/peps/pep-0008/)
[](https://github.com/psf/black)
[](http://mypy-lang.org/)
**async_multiplexer** is a TCP Multiplexer based on [Mplex](https://github.com/libp2p/specs/tree/master/mplex) protocol, but simplified.
It is intended for creating mutiple streams in parallel
on top of a same TCP connection.
## Installation
```bash
pip install async-multiplexer
```
## Usage
### Client
```python
import asyncio
from async_multiplexer import open_multiplexer_context
async def echo_client():
async with open_multiplexer_context("127.0.0.1", 7777) as multiplexer:
stream_echo_1 = await multiplexer.multiplex("echo.1")
stream_echo_2 = await multiplexer.multiplex("echo.2")
await stream_echo_1.write(b"echo.1")
await stream_echo_2.write(b"echo.2")
if __name__ == "__main__":
asyncio.run(echo_client())
```
### Server
```python
import asyncio
from async_multiplexer import bind_multiplex_listener_context
async def handler(stream):
data = await stream.read()
print(data)
async def echo_server():
async with bind_multiplex_listener_context("127.0.0.1", 7777) as listener:
listener.set_handler("echo.1", handler)
listener.set_handler("echo.2", handler)
await asyncio.sleep(10)
if __name__ == "__main__":
asyncio.run(echo_server())
```
نیازمندی
| مقدار | نام |
|---|---|
| ==1.2.0 | uvarint |
| ==5.4.1 | pytest |
| ==0.11.0 | pytest-asyncio |
| ==5.10.4 | hypothesis |
| ==0.19.0 | hypothesis-pytest |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8 | Python |
نحوه نصب
نصب پکیج whl async-multiplexer-0.1.0:
pip install async-multiplexer-0.1.0.whl
نصب پکیج tar.gz async-multiplexer-0.1.0:
pip install async-multiplexer-0.1.0.tar.gz