blob: 2b530e48af8b2f0fe141975f6409cd30f6a1040b (
plain)
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
|
import asyncio
from blinker.base import Signal
try:
schedule = asyncio.create_task
except AttributeError:
schedule = asyncio.ensure_future
@asyncio.coroutine
def _wrap_plain_value(value):
"""Pass through a coroutine *value* or wrap a plain value."""
if asyncio.iscoroutine(value):
value = yield from value
return value
def send_async(self, *sender, **kwargs):
return [(receiver, schedule(_wrap_plain_value(value)))
for receiver, value
in self.send(*sender, **kwargs)]
send_async.__doc__ = Signal.send_async.__doc__
Signal.send_async = send_async
|