Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skelmis/zonis
Agnostic IPC for Python programs
https://github.com/skelmis/zonis
Last synced: 2 months ago
JSON representation
Agnostic IPC for Python programs
- Host: GitHub
- URL: https://github.com/skelmis/zonis
- Owner: Skelmis
- License: mit
- Created: 2022-11-13T13:35:51.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T10:49:33.000Z (7 months ago)
- Last Synced: 2024-09-26T11:38:11.370Z (4 months ago)
- Language: Python
- Homepage: http://zonis.rtfd.io
- Size: 105 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Zonis
---A coro based callback system for many to one IPC setups.
`pip install zonis`
---
### Simplistic example
Client:
```python
import asynciofrom 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:
```python
import asyncio
import jsonfrom fastapi import FastAPI
from starlette.websockets import WebSocket, WebSocketDisconnectfrom zonis import UnknownClient
from zonis.server import Serverapp = 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](https://github.com/Skelmis/Zonis/tree/master/examples) directory for more use cases.
#### For documentation, please see [here](https://zonis.readthedocs.io/en/latest/).
---
### Support
Want realtime help? Join the discord [here](https://discord.gg/BqPNSH2jPg).
---
### Funding
Want a feature added quickly? Want me to help build your software using this?
Sponsor me [here](https://github.com/sponsors/Skelmis)