/usr/share/doc/python-pydispatch-doc/pydispatch.dispatcher.html is in python-pydispatch-doc 2.0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module pydispatch.dispatcher</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="pydispatch.html"><font color="#ffffff">pydispatch</font></a>.dispatcher</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/build/pydispatcher-098ajc/pydispatcher-2.0.5/pydispatch/dispatcher.py">/build/pydispatcher-098ajc/pydispatcher-2.0.5/pydispatch/dispatcher.py</a></font></td></tr></table>
<p><tt>Multiple-producer-multiple-consumer signal-dispatching<br>
<br>
dispatcher is the core of the PyDispatcher system,<br>
providing the primary API and the core logic for the<br>
system.<br>
<br>
Module attributes of note:<br>
<br>
Any -- Singleton used to signal either "Any Sender" or<br>
"Any Signal". See documentation of the <a href="#_Any">_Any</a> class.<br>
Anonymous -- Singleton used to signal "Anonymous Sender"<br>
See documentation of the <a href="#_Anonymous">_Anonymous</a> class.<br>
<br>
Internal attributes:<br>
WEAKREF_TYPES -- tuple of types/classes which represent<br>
weak references to receivers, and thus must be de-<br>
referenced on retrieval to retrieve the callable<br>
object<br>
connections -- { senderkey (id) : { signal : [receivers...]}}<br>
senders -- { senderkey (id) : weakref(sender) }<br>
used for cleaning up sender references on sender<br>
deletion<br>
sendersBack -- { receiverkey (id) : [senderkey (id)...] }<br>
used for cleaning up receiver references on receiver<br>
deletion, (considerably speeds up the cleanup process<br>
vs. the original code.)</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="pydispatch.errors.html">pydispatch.errors</a><br>
</td><td width="25%" valign=top><a href="pydispatch.robustapply.html">pydispatch.robustapply</a><br>
</td><td width="25%" valign=top><a href="pydispatch.saferef.html">pydispatch.saferef</a><br>
</td><td width="25%" valign=top><a href="weakref.html">weakref</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="pydispatch.dispatcher.html#_Parameter">_Parameter</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="pydispatch.dispatcher.html#_Anonymous">_Anonymous</a>
</font></dt><dt><font face="helvetica, arial"><a href="pydispatch.dispatcher.html#_Any">_Any</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="_Anonymous">class <strong>_Anonymous</strong></a>(<a href="pydispatch.dispatcher.html#_Parameter">_Parameter</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Singleton used to signal "Anonymous Sender"<br>
<br>
The Anonymous object is used to signal that the sender<br>
of a message is not specified (as distinct from being<br>
"any sender"). Registering callbacks for Anonymous<br>
will only receive messages sent without senders. Sending<br>
with anonymous will only send messages to those receivers<br>
registered for Any or Anonymous.<br>
<br>
Note:<br>
The default sender for connect is Any, while the<br>
default sender for send is Anonymous. This has<br>
the effect that if you do not specify any senders<br>
in either function then all messages are routed<br>
as though there was a single sender (Anonymous)<br>
being used everywhere.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods inherited from <a href="pydispatch.dispatcher.html#_Parameter">_Parameter</a>:<br>
<dl><dt><a name="_Anonymous-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="_Any">class <strong>_Any</strong></a>(<a href="pydispatch.dispatcher.html#_Parameter">_Parameter</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Singleton used to signal either "Any Sender" or "Any Signal"<br>
<br>
The Any object can be used with connect, disconnect,<br>
send, or sendExact to signal that the parameter given<br>
Any should react to all senders/signals, not just<br>
a particular sender/signal.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods inherited from <a href="pydispatch.dispatcher.html#_Parameter">_Parameter</a>:<br>
<dl><dt><a name="_Any-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="_Parameter">class <strong>_Parameter</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Used to represent default parameter values.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="_Parameter-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-_cleanupConnections"><strong>_cleanupConnections</strong></a>(senderkey, signal)</dt><dd><tt>Delete any empty signals for senderkey. Delete senderkey if empty.</tt></dd></dl>
<dl><dt><a name="-_killBackref"><strong>_killBackref</strong></a>(receiver, senderkey)</dt><dd><tt>Do the actual removal of back reference from receiver to senderkey</tt></dd></dl>
<dl><dt><a name="-_removeBackrefs"><strong>_removeBackrefs</strong></a>(senderkey)</dt><dd><tt>Remove all back-references to this senderkey</tt></dd></dl>
<dl><dt><a name="-_removeOldBackRefs"><strong>_removeOldBackRefs</strong></a>(senderkey, signal, receiver, receivers)</dt><dd><tt>Kill old sendersBack references from receiver<br>
<br>
This guards against multiple registration of the same<br>
receiver for a given signal and sender leaking memory<br>
as old back reference records build up.<br>
<br>
Also removes old receiver instance from receivers</tt></dd></dl>
<dl><dt><a name="-_removeReceiver"><strong>_removeReceiver</strong></a>(receiver)</dt><dd><tt>Remove receiver from connections.</tt></dd></dl>
<dl><dt><a name="-_removeSender"><strong>_removeSender</strong></a>(senderkey)</dt><dd><tt>Remove senderkey from connections.</tt></dd></dl>
<dl><dt><a name="-connect"><strong>connect</strong></a>(receiver, signal<font color="#909090">=_Any</font>, sender<font color="#909090">=_Any</font>, weak<font color="#909090">=True</font>)</dt><dd><tt>Connect receiver to sender for signal<br>
<br>
receiver -- a callable Python object which is to receive<br>
messages/signals/events. Receivers must be hashable<br>
objects.<br>
<br>
if weak is True, then receiver must be weak-referencable<br>
(more precisely saferef.safeRef() must be able to create<br>
a reference to the receiver).<br>
<br>
Receivers are fairly flexible in their specification,<br>
as the machinery in the robustApply module takes care<br>
of most of the details regarding figuring out appropriate<br>
subsets of the sent arguments to apply to a given<br>
receiver.<br>
<br>
Note:<br>
if receiver is itself a weak reference (a callable),<br>
it will be de-referenced by the system's machinery,<br>
so *generally* weak references are not suitable as<br>
receivers, though some use might be found for the<br>
facility whereby a higher-level library passes in<br>
pre-weakrefed receiver references.<br>
<br>
signal -- the signal to which the receiver should respond<br>
<br>
if Any, receiver will receive any signal from the<br>
indicated sender (which might also be Any, but is not<br>
necessarily Any).<br>
<br>
Otherwise must be a hashable Python object other than<br>
None (DispatcherError raised on None).<br>
<br>
sender -- the sender to which the receiver should respond<br>
<br>
if Any, receiver will receive the indicated signals<br>
from any sender.<br>
<br>
if Anonymous, receiver will only receive indicated<br>
signals from send/sendExact which do not specify a<br>
sender, or specify Anonymous explicitly as the sender.<br>
<br>
Otherwise can be any python object.<br>
<br>
weak -- whether to use weak references to the receiver<br>
By default, the module will attempt to use weak<br>
references to the receiver objects. If this parameter<br>
is false, then strong references will be used.<br>
<br>
returns None, may raise DispatcherTypeError</tt></dd></dl>
<dl><dt><a name="-disconnect"><strong>disconnect</strong></a>(receiver, signal<font color="#909090">=_Any</font>, sender<font color="#909090">=_Any</font>, weak<font color="#909090">=True</font>)</dt><dd><tt>Disconnect receiver from sender for signal<br>
<br>
receiver -- the registered receiver to disconnect<br>
signal -- the registered signal to disconnect<br>
sender -- the registered sender to disconnect<br>
weak -- the weakref state to disconnect<br>
<br>
disconnect reverses the process of connect,<br>
the semantics for the individual elements are<br>
logically equivalent to a tuple of<br>
(receiver, signal, sender, weak) used as a key<br>
to be deleted from the internal routing tables.<br>
(The actual process is slightly more complex<br>
but the semantics are basically the same).<br>
<br>
Note:<br>
Using disconnect is not required to cleanup<br>
routing when an object is deleted, the framework<br>
will remove routes for deleted objects<br>
automatically. It's only necessary to disconnect<br>
if you want to stop routing to a live object.<br>
<br>
returns None, may raise DispatcherTypeError or<br>
DispatcherKeyError</tt></dd></dl>
<dl><dt><a name="-getAllReceivers"><strong>getAllReceivers</strong></a>(sender<font color="#909090">=_Any</font>, signal<font color="#909090">=_Any</font>)</dt><dd><tt>Get list of all receivers from global tables<br>
<br>
This gets all receivers which should receive<br>
the given signal from sender, each receiver should<br>
be produced only once by the resulting generator</tt></dd></dl>
<dl><dt><a name="-getReceivers"><strong>getReceivers</strong></a>(sender<font color="#909090">=_Any</font>, signal<font color="#909090">=_Any</font>)</dt><dd><tt>Get list of receivers from global tables<br>
<br>
This utility function allows you to retrieve the<br>
raw list of receivers from the connections table<br>
for the given sender and signal pair.<br>
<br>
Note:<br>
there is no guarantee that this is the actual list<br>
stored in the connections table, so the value<br>
should be treated as a simple iterable/truth value<br>
rather than, for instance a list to which you<br>
might append new records.<br>
<br>
Normally you would use <a href="#-liveReceivers">liveReceivers</a>( <a href="#-getReceivers">getReceivers</a>( ...))<br>
to retrieve the actual receiver objects as an iterable<br>
object.</tt></dd></dl>
<dl><dt><a name="-liveReceivers"><strong>liveReceivers</strong></a>(receivers)</dt><dd><tt>Filter sequence of receivers to get resolved, live receivers<br>
<br>
This is a generator which will iterate over<br>
the passed sequence, checking for weak references<br>
and resolving them, then returning all live<br>
receivers.</tt></dd></dl>
<dl><dt><a name="-send"><strong>send</strong></a>(signal<font color="#909090">=_Any</font>, sender<font color="#909090">=_Anonymous</font>, *arguments, **named)</dt><dd><tt>Send signal from sender to all connected receivers.<br>
<br>
signal -- (hashable) signal value, see connect for details<br>
<br>
sender -- the sender of the signal<br>
<br>
if Any, only receivers registered for Any will receive<br>
the message.<br>
<br>
if Anonymous, only receivers registered to receive<br>
messages from Anonymous or Any will receive the message<br>
<br>
Otherwise can be any python object (normally one<br>
registered with a connect if you actually want<br>
something to occur).<br>
<br>
arguments -- positional arguments which will be passed to<br>
*all* receivers. Note that this may raise TypeErrors<br>
if the receivers do not allow the particular arguments.<br>
Note also that arguments are applied before named<br>
arguments, so they should be used with care.<br>
<br>
named -- named arguments which will be filtered according<br>
to the parameters of the receivers to only provide those<br>
acceptable to the receiver.<br>
<br>
Return a list of tuple pairs [(receiver, response), ... ]<br>
<br>
if any receiver raises an error, the error propagates back<br>
through send, terminating the dispatch loop, so it is quite<br>
possible to not have all receivers called if a raises an<br>
error.</tt></dd></dl>
<dl><dt><a name="-sendExact"><strong>sendExact</strong></a>(signal<font color="#909090">=_Any</font>, sender<font color="#909090">=_Anonymous</font>, *arguments, **named)</dt><dd><tt>Send signal only to those receivers registered for exact message<br>
<br>
sendExact allows for avoiding Any/Anonymous registered<br>
handlers, sending only to those receivers explicitly<br>
registered for a particular signal on a particular<br>
sender.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>Anonymous</strong> = _Anonymous<br>
<strong>Any</strong> = _Any<br>
<strong>WEAKREF_TYPES</strong> = (<type 'weakref'>, <class 'pydispatch.saferef.BoundMethodWeakref'>)<br>
<strong>__file__</strong> = '/build/pydispatcher-098ajc/pydispatcher-2.0.5/pydispatch/dispatcher.py'<br>
<strong>__name__</strong> = 'pydispatch.dispatcher'<br>
<strong>__package__</strong> = 'pydispatch'<br>
<strong>connections</strong> = {}<br>
<strong>senders</strong> = {}<br>
<strong>sendersBack</strong> = {}</td></tr></table>
</body></html>
|