MCPcopy
hub / github.com/aio-libs/aiohttp / Signal

Class Signal

aiohttp/signals.py:21–50  ·  view source on GitHub ↗

Coroutine-based signal implementation. To connect a callback to a signal, use any list method. Signals are fired using the :meth:`send` coroutine, which takes named arguments.

Source from the content-addressed store, hash-verified

19
20
21class Signal(BaseSignal):
22 """Coroutine-based signal implementation.
23
24 To connect a callback to a signal, use any list method.
25
26 Signals are fired using the :meth:`send` coroutine, which takes named
27 arguments.
28 """
29
30 def __init__(self, app):
31 super().__init__()
32 self._app = app
33 klass = self.__class__
34 self._name = klass.__module__ + ':' + klass.__qualname__
35 self._pre = app.on_pre_signal
36 self._post = app.on_post_signal
37
38 @asyncio.coroutine
39 def send(self, *args, **kwargs):
40 """
41 Sends data to all registered receivers.
42 """
43 ordinal = None
44 debug = self._app._debug
45 if debug:
46 ordinal = self._pre.ordinal()
47 yield from self._pre.send(ordinal, self._name, *args, **kwargs)
48 yield from self._send(*args, **kwargs)
49 if debug:
50 yield from self._post.send(ordinal, self._name, *args, **kwargs)
51
52
53class DebugSignal(BaseSignal):

Callers 8

test_non_coroutineFunction · 0.90
test_copy_forbiddenFunction · 0.90
test_sort_forbiddenFunction · 0.90
test_debug_signalFunction · 0.90
makerFunction · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by 7

test_non_coroutineFunction · 0.72
test_copy_forbiddenFunction · 0.72
test_sort_forbiddenFunction · 0.72
test_debug_signalFunction · 0.72
makerFunction · 0.72