Skip to main content

Coverage CI Test suite

Package version

Smart Connection

What is it?

Smart Connection (SC) is a a lightweight wrapper around asyncio TCP connection for building distributed systems. It provides a higher level API in the spirit of ZeroMQ.

Main features

Exchange message, not bytes

In contrast to TCP, which is a stream-oriented protocol, SC is a message-based protocol. This means that SC guarantees the delivery of each message as a distinct unit and in the correct order. In practice, each message is encapsulated within a frame that ensures its integrity. The protocol is simple and can be easily implemented in any other modern programming language.

User friendly API

Users can send and receive messages directly. Serialization and deserialization are handled transparently by the library. Messages can be received from a connection object using an async for loop, allowing for elegant user code.

A simple echo server example

Server

import asyncio
from smart_connection import Connection, wrap_server_connection_handler


@wrap_server_connection_handler
async def handle_connection(connection: Connection):
    async for message in connection:
        await connection.send(f"server replied: {message}")


async def main():
    async with await asyncio.start_server(handle_connection, "127.0.0.1", 8888) as server:
        await server.serve_forever()

Client

import asyncio
import aioconsole
from smart_connection import wrap_client_connection_handler


async def main():
    connection_ends = await asyncio.open_connection("127.0.0.1", 8888)
    async with wrap_client_connection_handler(connection_ends) as connection:
        while True:
            message = await aioconsole.ainput(">>> ")
            await connection.send(message)
            print(await connection.receive())

Metadata

Release files for smart_connection 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 smart_connection 0.1.0
File Size Uploaded Provenance
smart_connection-0.1.0.tar.gz 26.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 30.7 kB

Release files / smart_connection-0.1.0.tar.gz

Download URL smart_connection-0.1.0.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
eb0dc0f5da12a37ec9fc8273b8831d6c77b9fe734f7dd3b49a5ac5b664e85607
BLAKE2b-256 checksum
How to use checksums
a7fbcdfcf14f8c1b71bbdb57d3f84e2d9e5a29b19d94326de54259727fc37182
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.3

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

Download URL smart_connection-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2894d3b8dab5a3a4535f6db5f680a6d09d9a33f94b2b6bc5d0dca96209b684f
BLAKE2b-256 checksum
How to use checksums
706bb4ce5c08310c9d0ea03fb1670deded5055fc1b559c1391ee321e8ea22497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.3

Security for smart_connection 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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