All public API members can (and should) be imported from blinker:
from blinker import ANY, signal
Sent by a Signal after a receiver connects.
Argument: | the Signal that was connected to |
---|---|
Parameters: |
|
Deprecated since version 1.2.
As of 1.2, individual signals have their own private receiver_connected and receiver_disconnected signals with a slightly simplified call signature. This global signal is planned to be removed in 1.6.
A notification emitter.
Parameter: | doc – optional. If provided, will be assigned to the signal’s __doc__ attribute. |
---|
Emitted after each connect().
The signal sender is the signal instance, and the connect() arguments are passed through: receiver, sender, and weak.
New in version 1.2.
Emitted after disconnect().
The sender is the signal instance, and the disconnect() arguments are passed through: receiver and sender.
Note, this signal is emitted only when disconnect() is called explicitly.
The disconnect signal can not be emitted by an automatic disconnect (due to a weakly referenced receiver or sender going out of scope), as the receiver and/or sender instances are no longer available for use at the time this signal would be emitted.
An alternative approach is available by subscribing to receiver_connected and setting up a custom weakref cleanup callback on weak receivers and senders.
New in version 1.2.
A mapping of connected receivers.
The values of this mapping are not meaningful outside of the internal Signal implementation, however the boolean value of the mapping is useful as an extremely efficient check to see if any receivers are connected to the signal.
Connect receiver to signal events sent by sender.
Parameters: |
|
---|
Connect the decorated function as a receiver for sender.
Parameters: |
|
---|
New in version 1.1.
Execute a block with the signal temporarily connected to receiver.
Parameters: |
|
---|
This is a context manager for use in the with statement. It can be useful in unit tests. receiver is connected to the signal for the duration of the with block, and will be disconnected automatically when exiting the block:
with on_ready.connected_to(receiver):
# do stuff
on_ready.send(123)
New in version 1.1.
Disconnect receiver from this signal’s events.
Parameters: |
---|
True if there is probably a receiver for sender.
Performs an optimistic check only. Does not guarantee that all weakly referenced receivers are still alive. See receivers_for() for a stronger search.
Emit this signal on behalf of sender, passing on **kwargs.
Returns a list of 2-tuples, pairing receivers with their return value. The ordering of receiver notification is undefined.
Parameters: |
|
---|
An alias for connected_to().
Parameters: |
|
---|
New in version 0.9.
Changed in version 1.1: Renamed to connected_to(). temporarily_connected_to was deprecated in 1.2 and removed in a subsequent version.
Return the NamedSignal name, creating it if required.
Repeated calls to this function will return the same signal object. Signals are created in a global Namespace.
Bases: blinker.base.Signal
A named generic notification emitter.
Bases: weakref.WeakValueDictionary
A mapping of signal names to signals.
Return the NamedSignal name, creating it if required.
Repeated calls to this function will return the same signal object.