summaryrefslogtreecommitdiff
path: root/blinker/playground.py
diff options
context:
space:
mode:
Diffstat (limited to 'blinker/playground.py')
-rw-r--r--blinker/playground.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/blinker/playground.py b/blinker/playground.py
new file mode 100644
index 0000000..8ed30fb
--- /dev/null
+++ b/blinker/playground.py
@@ -0,0 +1,20 @@
+import blinker
+
+
+def quash_exceptions(fn, sender, kwargs):
+ """Always call all receivers, collecting values or exceptions."""
+ try:
+ return fn(sender, **kwargs), None
+ except Exception as exc:
+ return None, exc
+
+
+def _adapt_xyz(fn, sender, kwargs):
+ return fn(sender, kwargs['x'], kwargs['y'], kwargs['z'])
+
+class PositionalSignal(blinker.Signal):
+ """Positional send and receive (x, y, z)"""
+ receiver_adapter = staticmethod(_adapt_xyz)
+
+ def send(self, sender, x, y, z):
+ return blinker.Signal.send(self, sender, x=x, y=y, z=z)