1
"""Module implementing error-catching version of send (sendRobust)"""
2
from grass.pydispatch.dispatcher import Any, Anonymous, liveReceivers, getAllReceivers
3
from grass.pydispatch.robustapply import robustApply
11
"""Send signal from sender to all connected receivers catching errors
13
signal -- (hashable) signal value, see connect for details
15
sender -- the sender of the signal
17
if Any, only receivers registered for Any will receive
20
if Anonymous, only receivers registered to receive
21
messages from Anonymous or Any will receive the message
23
Otherwise can be any python object (normally one
24
registered with a connect if you actually want
27
arguments -- positional arguments which will be passed to
28
*all* receivers. Note that this may raise TypeErrors
29
if the receivers do not allow the particular arguments.
30
Note also that arguments are applied before named
31
arguments, so they should be used with care.
33
named -- named arguments which will be filtered according
34
to the parameters of the receivers to only provide those
35
acceptable to the receiver.
37
Return a list of tuple pairs [(receiver, response), ... ]
39
if any receiver raises an error (specifically any subclass of Exception),
40
the error instance is returned as the result for that receiver.
42
# Call each receiver with whatever arguments it can accept.
43
# Return a list of tuple pairs [(receiver, response), ... ].
45
for receiver in liveReceivers(getAllReceivers(sender, signal)):
47
response = robustApply(
54
except Exception as err:
55
responses.append((receiver, err))
57
responses.append((receiver, response))