Skip to main content
Pre-release

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

Latest PyPI Version Latest PyPI Version

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

pydispatcher-2.0.9a1.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

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

pydispatcher-2.0.9a1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

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

Hashes for pydispatcher-2.0.9a1.tar.gz
Algorithm Hash digest
SHA256 b65c38b487b6adb6c8a65fb13f1d4907fd293b84fdb723f66a0ef1c68fbbb29f
MD5 03391d6625f7a06e9a3085d2cb72a6cd
BLAKE2b-256 5efcd03be994630181add212c56f65acb026aba8eaeaf1abcdfc6984cab003ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydispatcher-2.0.9a1.tar.gz:

Publisher: release.yml on mcfletch/pydispatcher

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

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

Hashes for pydispatcher-2.0.9a1-py3-none-any.whl
Algorithm Hash digest
SHA256 1fa2f13d1d49e14baa19f8443784ca533827b01ef2b83dc930eecb486a596bd3
MD5 c85607f6bff965970378dc4fa38ea191
BLAKE2b-256 a476236c4d1225fcb0212bc0e5269da8534878c812fa9ab6931083a2c19b3df1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydispatcher-2.0.9a1-py3-none-any.whl:

Publisher: release.yml on mcfletch/pydispatcher

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

Release history Release notifications | RSS feed

This release

2.0.9a1 This release

2 files

2.0.7

2 files

2.0.6

1 file

2.0.5

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

1 file

2.0.1

1 file

1.0.2

1.0.1

1.0.0

1.0.0a1

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