summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouri Ackx <varia@ackx.net>2020-10-02 17:17:42 +0200
committerYouri Ackx <varia@ackx.net>2020-10-02 17:17:42 +0200
commitc7b83a18a54efa9e08a9446e2d16956ee5fe353b (patch)
treebd1b990085874249de3f1df77bc293a8ac44af67
parent5936e96bb059dc766d0e87fc569f61dfb5eca963 (diff)
downloadblinker-c7b83a18a54efa9e08a9446e2d16956ee5fe353b.tar.gz
Document support for send_async
-rw-r--r--README.md3
-rw-r--r--docs/source/index.rst30
2 files changed, 33 insertions, 0 deletions
diff --git a/README.md b/README.md
index 907a3ec..e9963a6 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,9 @@ interested parties to subscribe to events, or "signals".
Signal receivers can subscribe to specific senders or receive signals
sent by any sender.
+It supports dispatching to an arbitrary mix of connected
+coroutines and receiver functions.
+
```python
>>> from blinker import signal
>>> started = signal('round-started')
diff --git a/docs/source/index.rst b/docs/source/index.rst
index bdb40ef..521e7c5 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -14,6 +14,7 @@ The core of Blinker is quite small but provides powerful features:
- sending arbitrary data payloads
- collecting return values from signal receivers
- thread safety
+ - coroutines as signal receivers
Blinker was written by Jason Kirtand and is provided under the MIT
License. The library supports Python 2.7 and Python 3.5 or later;
@@ -94,6 +95,35 @@ notifications being sent, and these no-op sends are optimized to be as
inexpensive as possible.
+Async support
+-------------
+
+Send a signal asynchronously to coroutine receivers.
+
+ >>> async def receiver_a(sender):
+ ... return 'value a'
+ ...
+ >>> async def receiver_b(sender):
+ ... return 'value b'
+ ...
+ >>> ready = signal('ready')
+ >>> ready.connect(receiver_a)
+ >>> ready.connect(receiver_b)
+ ...
+ >>> async def collect():
+ ... return ready.send_async('sender')
+ ...
+ >>> loop = asyncio.get_event_loop()
+ >>> results = loop.run_until_complete(collect())
+ >>> len(results)
+ 2
+ >>> [v.result() for r, v in results][0]
+ value a
+
+Dispatching to an arbitrary mix of connected
+coroutines and receiver functions is supported.
+
+
Subscribing to Specific Senders
-------------------------------