File: signals.rst

package info (click to toggle)
python-aiohttp 3.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,640 kB
  • sloc: python: 40,369; ansic: 15,798; makefile: 382
file content (45 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Signals
=======

.. currentmodule:: aiohttp

Signal is a list of registered asynchronous callbacks.

The signal's life-cycle has two stages: after creation its content
could be filled by using standard list operations: ``sig.append()``
etc.

After ``sig.freeze()`` call the signal is *frozen*: adding, removing
and dropping callbacks are forbidden.

The only available operation is calling previously registered
callbacks by ``await sig.send(data)``.

For concrete usage examples see :ref:`signals in aiohttp.web
<aiohttp-web-signals>` chapter.

.. versionchanged:: 3.0

   ``sig.send()`` call is forbidden for non-frozen signal.

   Support for regular (non-async) callbacks is dropped. All callbacks
   should be async functions.


.. class:: Signal

   The signal, implements :class:`collections.abc.MutableSequence`
   interface.

   .. comethod:: send(*args, **kwargs)

      Call all registered callbacks one by one starting from the begin
      of list.

   .. attribute:: frozen

      ``True`` if :meth:`freeze` was called, read-only property.

   .. method:: freeze()

      Freeze the list. After the call any content modification is forbidden.