pydispatch.dispatcher

Multiple-producer-multiple-consumer signal-dispatching
dispatcher is the core of the PyDispatcher system, providing the primary API and the core logic for the system.
Module attributes of note:
Any
Singleton used to signal either "Any Sender" or "Any Signal". See documentation of the _Any class.
Anonymous
Singleton used to signal "Anonymous Sender" See documentation of the _Anonymous class.
Internal attributes: WEAKREF_TYPES -- tuple of types/classes which represent weak references to receivers, and thus must be de- referenced on retrieval to retrieve the callable object connections -- { senderkey (id) : { signal : senders -- { senderkey (id) : weakref(sender) } used for cleaning up sender references on sender deletion sendersBack -- { receiverkey (id) : [senderkey (id)... } used for cleaning up receiver references on receiver deletion, (considerably speeds up the cleanup process vs. the original code.)

Functions

connect( receiver , signal = _Any , sender = _Any , weak = True )
Connect receiver to sender for signal
receiver
a callable Python object which is to receive messages/signals/events. Receivers must be hashable objects.
if weak is True, then receiver must be weak-referencable (more precisely saferef.safeRef() must be able to create a reference to the receiver).
Receivers are fairly flexible in their specification, as the machinery in the robustApply module takes care of most of the details regarding figuring out appropriate subsets of the sent arguments to apply to a given receiver.
Note: if receiver is itself a weak reference (a callable), it will be de-referenced by the system's machinery, so *generally* weak references are not suitable as receivers, though some use might be found for the facility whereby a higher-level library passes in pre-weakrefed receiver references.
signal
the signal to which the receiver should respond
if Any, receiver will receive any signal from the indicated sender (which might also be Any, but is not necessarily Any).
Otherwise must be a hashable Python object other than None (DispatcherError raised on None).
sender
the sender to which the receiver should respond
if Any, receiver will receive the indicated signals from any sender.
if Anonymous, receiver will only receive indicated signals from send/sendExact which do not specify a sender, or specify Anonymous explicitly as the sender.
Otherwise can be any python object.
weak
whether to use weak references to the receiver By default, the module will attempt to use weak references to the receiver objects. If this parameter is false, then strong references will be used.
returns None, may raise DispatcherTypeError