Skip to main content

Zonis

A coro based callback system for many to one IPC setups.

pip install zonis


Simplistic example

Client:

import asyncio

from zonis import Client


async def main():
    client = Client(url="localhost:12344/ws")

    @client.route()
    async def ping():
        print("Pong'd!")
        return "pong"

    await client.start()
    await client.block_until_closed()


asyncio.run(main())

Server:

import asyncio
import json

from fastapi import FastAPI
from starlette.websockets import WebSocket, WebSocketDisconnect

from zonis import UnknownClient
from zonis.server import Server

app = FastAPI()
server = Server(using_fastapi_websockets=True)


@app.get("/")
async def index():
    try:
        response = await server.request("ping")
        return {"data": response}  # Returns pong
    except UnknownClient as e:
        return e


@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()
    d: str = await websocket.receive_text()
    identifier = await server.parse_identify(json.loads(d), websocket)

    try:
        await asyncio.Future()
    except WebSocketDisconnect:
        await server.disconnect(identifier)
        print(f"Closed connection for {identifier}")

See the examples directory for more use cases.

For documentation, please see here.


Support

Want realtime help? Join the discord here.


Funding

Want a feature added quickly? Want me to help build your software using this?

Sponsor me here

Metadata

Release files for zonis 2.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 zonis 2.1.0
File Size Uploaded
zonis-2.1.0.tar.gz 11.5 kB Details

Built distribution (wheel)

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

Total release size: 25.7 kB

Release files / zonis-2.1.0.tar.gz

Download URL zonis-2.1.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aea29117ab4b3772c59fa6a0a9b2dfff5e3711485ea3b26974eb73831f0460c0
BLAKE2b-256 checksum
How to use checksums
8727eb91834388a4d783c0d6af63bfd47d102160614270790a4ed1acc20ac3f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-35-generic

Release files / zonis-2.1.0-py3-none-any.whl

Download URL zonis-2.1.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08e7750dc1da9ca6e69a14a74388d0e4df427cd6aeb0f899f104ea1eed214c11
BLAKE2b-256 checksum
How to use checksums
a1f332cbb95a35f7b37064da5b8e2eba6160527c210803d30224100a6939e8f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-35-generic

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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