Skip to main content

Async Python IPC using WebSockets

Project description

wsipc

Async Python IPC using WebSockets

Server Example (Simple Broker)

from asyncio import run

from wsipc import WSIPCServer

server = WSIPCServer(heartbeat=45)

run(server.start(block=True))

Client Example

from asyncio import create_task, run, sleep

from wsipc import WSIPCClient


client = WSIPCClient()

@client.listener()
async def on_message(message):
    print(message)

@client.listener()
def sync_listener(message):
    print(message)

async def main() -> None:
    create_task(client.connect())

    await client.connected.wait()

    await client.send("Hello World!")

    await sleep(1)

    await client.close()

run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsipc-0.0.3.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

wsipc-0.0.3-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page