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.
🚀 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59a778ad64cf40d9328b9770570c05000fbf640d1900085c25189d60c5863a40
|
|
| MD5 |
8e8fcc1ceaad37760b3a41899f0a519b
|
|
| BLAKE2b-256 |
42256efcc22a27baa8fc1864323c186534b8ce1791957eced48a86411e732861
|
Provenance
The following attestation bundles were made for event_pubsub-0.0.2.tar.gz:
Publisher:
publish.yml on Seungkyu-Han/event-pubsub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
event_pubsub-0.0.2.tar.gz -
Subject digest:
59a778ad64cf40d9328b9770570c05000fbf640d1900085c25189d60c5863a40 - Sigstore transparency entry: 1193175715
- Sigstore integration time:
-
Permalink:
Seungkyu-Han/event-pubsub@b0f38a04f22b0d76d97c5763f44de1e6c6bd0ec8 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/Seungkyu-Han
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0f38a04f22b0d76d97c5763f44de1e6c6bd0ec8 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
552dbbd61ac8afb0ebc8728bcd4e24b2d9a0949e7fd0068d442d5dff1d3a599e
|
|
| MD5 |
f7542245316c59e754d7145dc4da727e
|
|
| BLAKE2b-256 |
bcb38a869873b19349a1388ffa996fe52f4953bfbdd8cf700d6799823dc4f15d
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
event_pubsub-0.0.2-py3-none-any.whl -
Subject digest:
552dbbd61ac8afb0ebc8728bcd4e24b2d9a0949e7fd0068d442d5dff1d3a599e - Sigstore transparency entry: 1193175822
- Sigstore integration time:
-
Permalink:
Seungkyu-Han/event-pubsub@b0f38a04f22b0d76d97c5763f44de1e6c6bd0ec8 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/Seungkyu-Han
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0f38a04f22b0d76d97c5763f44de1e6c6bd0ec8 -
Trigger Event:
push
-
Statement type: