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)
| File | Size | Uploaded | |
|---|---|---|---|
| zonis-2.1.0.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|