Skip to main content

A powerful, NestJS-inspired event emitter for Python with wildcard and async support.

Project description

Event Pub/Sub Library

A simple and flexible asynchronous Event Pub/Sub library for Python.

PyPI version codecov PyPI downloads license


🚀 Installation

Install via pip:

pip install event-pubsub

Or install locally for development:

pip install -e .

📦 Usage

1. Subscribe to an event

from event_pubsub import subscriber

@subscriber.subscribe(event_type="hello")
def event_handler(name: str):
    print(f'hello {name} from sync')

2. publish an event

from event_pubsub import publisher

async def say_hello(name: str):
    await publisher.publish('hello', name)
    return {"message": "success"}

3. Passing multiple arguments

from event_pubsub import subscriber

@subscriber.subscribe(event_type="hello")
async def handle_message(user_id: int, message: str):
    print(user_id, message)

4. Multiple handlers

from event_pubsub import subscriber

@subscriber.subscribe("event")
async def handler1(data):
    print("handler1", data)

@subscriber.subscribe("event")
async def handler2(data):
    print("handler2", data)

⚙️ Configuration

Event Types

Events are identified by string keys:

"user_created"
"order_completed"
"message_received"

Argument Passing

The emit method supports flexible arguments:

from event_pubsub import publisher

await publisher.publish("event", 1, 2, 3)

📄 License

MIT License

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

event_pubsub-0.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

event_pubsub-0.0.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file event_pubsub-0.0.2.tar.gz.

File metadata

  • Download URL: event_pubsub-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for event_pubsub-0.0.2.tar.gz
Algorithm Hash digest
SHA256 59a778ad64cf40d9328b9770570c05000fbf640d1900085c25189d60c5863a40
MD5 8e8fcc1ceaad37760b3a41899f0a519b
BLAKE2b-256 42256efcc22a27baa8fc1864323c186534b8ce1791957eced48a86411e732861

See more details on using hashes here.

Provenance

The following attestation bundles were made for event_pubsub-0.0.2.tar.gz:

Publisher: publish.yml on Seungkyu-Han/event-pubsub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file event_pubsub-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: event_pubsub-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for event_pubsub-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 552dbbd61ac8afb0ebc8728bcd4e24b2d9a0949e7fd0068d442d5dff1d3a599e
MD5 f7542245316c59e754d7145dc4da727e
BLAKE2b-256 bcb38a869873b19349a1388ffa996fe52f4953bfbdd8cf700d6799823dc4f15d

See more details on using hashes here.

Provenance

The following attestation bundles were made for event_pubsub-0.0.2-py3-none-any.whl:

Publisher: publish.yml on Seungkyu-Han/event-pubsub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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