Skip to main content
https://img.shields.io/pypi/v/signaling.svg?style=flat-square https://img.shields.io/travis/mdomke/signaling/master.svg?style=flat-square https://img.shields.io/pypi/l/signaling.svg?style=flat-square

What is this?

signaling is a simple implementation of the signal/slot pattern as known from the Qt framework. It has no external requirements and 100% test-coverage.

Installation

The usual

pip install signaling

How to use it?

Consider that you have a function that should be called whenever a connected signal is emitted, as illustrated by the following code block:

def slot(arg):
  print("Slot called with {}".format(arg))

signal = Signal(args=['arg'])
signal.connect(slot)
signal.emit(arg=1)  # Slot called with 1

In fact you can connect multiple slots to the same signal, as long as they share the same function signature.

Notice that the signaling library performs some sanity checks when connecting slots and emitting signals.

  • All slots connected to a signal have to provide the same argument specifiction as denoted by the args parameter of the Signal constructor.

  • An emit-call has to be made with the exact same arguments as specified with the Signal constructor.

So all of the below examples would raise an exception:

def slot_with_arg(arg):
  pass

def slot_without_arg():
  pass

# InvalidSlot: Slot 'slot_with_arg' has to callable without arguments
Signal().connect(slot_with_arg)

# InvalidSlot: Slot 'slot_without_args' has to accept args ['arg'] or **kwargs.
Signal(args['arg']).connect(slot_without_arg)

s = Signal()
s.connect(slot_without_args)
# InvalidEmit: Emit has to be called without arguments.
s.emit(foo=1)

Metadata

Release files for signaling 0.0.2

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

Built distribution (wheel)

Table of built distributions (wheels) for signaling 0.0.2
File Interpreter ABI Platform
signaling-0.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / signaling-0.0.2-py2.py3-none-any.whl

Download URL signaling-0.0.2-py2.py3-none-any.whl
Size 5.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
afe93eb37f93807a205bf79cbddee7e468c710463e148ff159abafb0c5a72f30
BLAKE2b-256 checksum
How to use checksums
bdb049dae878106f102bbad38446ee77fb6450a1c790bb5e5f7e819dbedc3eb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0.0

2 release files

0.0.4

1 release file

0.0.3

2 release files

This release

0.0.2 This release

1 release file

0.0.0

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