Agnostic IPC for Python programs
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zonis-2.1.0.tar.gz.
File metadata
- Download URL: zonis-2.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-35-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aea29117ab4b3772c59fa6a0a9b2dfff5e3711485ea3b26974eb73831f0460c0
|
|
| MD5 |
76c6283b8a05b5ebc7ef27bb5f2888b4
|
|
| BLAKE2b-256 |
8727eb91834388a4d783c0d6af63bfd47d102160614270790a4ed1acc20ac3f8
|
File details
Details for the file zonis-2.1.0-py3-none-any.whl.
File metadata
- Download URL: zonis-2.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-35-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08e7750dc1da9ca6e69a14a74388d0e4df427cd6aeb0f899f104ea1eed214c11
|
|
| MD5 |
2216d894c0a66dd24f930a32c6e2aea2
|
|
| BLAKE2b-256 |
a1f332cbb95a35f7b37064da5b8e2eba6160527c210803d30224100a6939e8f5
|