Skip to main content

async_multiplexer

PyPI version Python 3.8 Build Status codecov

PEP8 black Checked with mypy

async_multiplexer is a TCP Multiplexer based on Mplex protocol, but simplified. It is intended for creating mutiple streams in parallel on top of a same TCP connection.

Installation

pip install async-multiplexer

Usage

Client

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

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

Metadata

Release files for async-multiplexer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for async-multiplexer 0.1.0
File Size Uploaded
async_multiplexer-0.1.0.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for async-multiplexer 0.1.0
File Interpreter ABI Platform
async_multiplexer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / async_multiplexer-0.1.0.tar.gz

Download URL async_multiplexer-0.1.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
32a642790b5ea46830cb174019c9784c7e3e6005fcf461a4f5d68b1f0c7d5562
BLAKE2b-256 checksum
How to use checksums
094ee7c42803dee68e62cd3030fea20a3184459044326554d7434b97c0e318f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release files / async_multiplexer-0.1.0-py3-none-any.whl

Download URL async_multiplexer-0.1.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c26cda3f5455e89009be65ebc4c1ec980629f23d29d1ddf89e1bb1579e5b554
BLAKE2b-256 checksum
How to use checksums
bc8719d50ac8aab36097db7022d8453fb55d8fc7e4e0ea48ceae9cf1a12c0f90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page