This release is a pre-release and may not be stable for production use.
PyDispatcher Multi-producer Multi-consumer Observables
PyDispatcher provides the Python programmer with a multiple-producer-multiple-consumer signal-registration and routing infrastructure for use in multiple contexts. The mechanism of PyDispatcher started life as a highly rated recipe in the Python Cookbook. The project aims to include various enhancements to the recipe developed during use in various applications. It is primarily maintained by Mike Fletcher. A derivative of the project provides the Django web framework's "signal" system.
Installation
PyDispatcher is available on PyPI via standard PIP:
pip install PyDispatcher
Usage
Documentation is available for detailed usage, but the basic idea is:
from pydispatch import dispatcher
metaKey = "moo"
MyNode = object()
event = {"sample": "event"}
def callback(event=None):
"""Handle signal being sent"""
print("Signal received", event)
dispatcher.connect(callback, sender=MyNode, signal=metaKey)
dispatcher.send(metaKey, MyNode, event=event)
Scaling
Two structures keep dispatch cost proportional to the work a signal actually implies rather than to the size of the program around it.
Wiring many receivers to one sender. connect() guards against registering
the same receiver twice for a (sender, signal) pair. An index of what is
already registered answers that in constant time, so wiring N receivers to a
shared sender costs O(N) rather than O(N²). The index is an optimisation hint:
every real registration records itself there, so "not registered" is always
trustworthy, and a stale "registered" costs one scan and nothing else.
Calling a receiver. robustApply passes a receiver only the arguments it
will accept, which means knowing its parameters. Those come from the receiver's
code object, which never changes, so they are derived once and reused --
robustapply.SIGNATURE_CACHE_SIZE bounds how many are remembered. A call with
no keyword arguments needs no signature at all, since there is nothing to
subset.
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 pydispatcher-2.0.9a1.tar.gz.
File metadata
- Download URL: pydispatcher-2.0.9a1.tar.gz
- Upload date:
- Size: 45.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65c38b487b6adb6c8a65fb13f1d4907fd293b84fdb723f66a0ef1c68fbbb29f
|
|
| MD5 |
03391d6625f7a06e9a3085d2cb72a6cd
|
|
| BLAKE2b-256 |
5efcd03be994630181add212c56f65acb026aba8eaeaf1abcdfc6984cab003ea
|
Provenance
The following attestation bundles were made for pydispatcher-2.0.9a1.tar.gz:
Publisher:
release.yml on mcfletch/pydispatcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydispatcher-2.0.9a1.tar.gz -
Subject digest:
b65c38b487b6adb6c8a65fb13f1d4907fd293b84fdb723f66a0ef1c68fbbb29f - Sigstore transparency entry: 2803227068
- Sigstore integration time:
-
Permalink:
mcfletch/pydispatcher@1fb9fa0f845cd765aee9cb2dd3d97a91bc4c8212 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mcfletch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1fb9fa0f845cd765aee9cb2dd3d97a91bc4c8212 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pydispatcher-2.0.9a1-py3-none-any.whl.
File metadata
- Download URL: pydispatcher-2.0.9a1-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fa2f13d1d49e14baa19f8443784ca533827b01ef2b83dc930eecb486a596bd3
|
|
| MD5 |
c85607f6bff965970378dc4fa38ea191
|
|
| BLAKE2b-256 |
a476236c4d1225fcb0212bc0e5269da8534878c812fa9ab6931083a2c19b3df1
|
Provenance
The following attestation bundles were made for pydispatcher-2.0.9a1-py3-none-any.whl:
Publisher:
release.yml on mcfletch/pydispatcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydispatcher-2.0.9a1-py3-none-any.whl -
Subject digest:
1fa2f13d1d49e14baa19f8443784ca533827b01ef2b83dc930eecb486a596bd3 - Sigstore transparency entry: 2803227145
- Sigstore integration time:
-
Permalink:
mcfletch/pydispatcher@1fb9fa0f845cd765aee9cb2dd3d97a91bc4c8212 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mcfletch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1fb9fa0f845cd765aee9cb2dd3d97a91bc4c8212 -
Trigger Event:
push
-
Statement type: