Skip to main content

Redis Events

Event based distributed computing using Redis and asyncio

Usage

Create a worker that will respond to events:

# worker.py

from redis_events import Client, Event

# Point client at Redis server
client = Client(
    host="mywebsite.com",
    port=6379,
    password="PASSWORD123"
)


@client.event("echo")  # name the event whatever you want
async def echo_example(event: Event):
    reply_event = Event(
        "echo", # this doesn't actually matter because it is a reply
        event.data  # echo the data that was in the first event
    )

    await client.send_reply(event, reply_event)

client.run()

Create a script that will push events

# send_events.py

from redis_events import Client
import asyncio

# obviously, must point to the same Redis server as the worker
client = Client(
    host="mywebsite.com",
    port=6379,
    password="PASSWORD123"
)

# Everything is async
async def send_events():
    my_event = Event(
        "echo",
        {"test": 1234}
    )

    await client.send(my_event)

    reply = await client.wait_for_reply(to=my_event, timeout=60)  # wait for a reply for up to 1 minute

    print("GOT REPLY")


asyncio.get_event_loop().run_until_complete(send_events())

Installation

pip install redis-events

Release files for redis-events 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redis-events 0.0.2
File Size Uploaded
redis-events-0.0.2.tar.gz 2.9 kB Details

Release files / redis-events-0.0.2.tar.gz

Download URL redis-events-0.0.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aa891b9d04f8034ee447bfd813006c201324f58016d1b807607a9a940b38a9e0
BLAKE2b-256 checksum
How to use checksums
3f1fe874af786543207ca0fc7ca1c4f8d7198b93fce353f152d95ab0a5639cb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

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