Debian Codegraph @

docs/index.rst

raw
1 aiosignal
2 =========
3
4 A project to manage callbacks in `asyncio` projects.
5
6 ``Signal`` is a list of registered asynchronous callbacks.
7
8 The signal's life-cycle has two stages: after creation its content
9 could be filled by using standard list operations: ``sig.append()``
10 etc.
11
12 After you call ``sig.freeze()`` the signal is *frozen*: adding, removing
13 and dropping callbacks is forbidden.
14
15 The only available operation is calling the previously registered
16 callbacks by using ``await sig.send(data)``.
17
18 The callback parameters, which should be passed in the ``.send()`` call, can be
19 specified for a type checker:
20
21 ```python
22 signal = Signal[int, str](owner)
23 signal.send(42, "foo")
24 ```
25
26 For concrete usage examples see the :ref:`aiohttp:aiohttp-web-signals` section of the :doc:`aiohttp:web_advanced` chapter of the :doc:`aiohttp documentation <aiohttp:index>`.
27
28 API
29 ---
30
31 .. class:: aiosignal.Signal(owner)
32
33 The signal, implements the :class:`collections.abc.MutableSequence`
34 interface. The *owner* object is shown in the signal representation,
35 and is there to make debugging easier.
36
37 .. method:: send(*args, **kwargs)
38 :async:
39
40 Call all registered callbacks one by one starting from the beginning
41 of the list.
42
43 .. attribute:: frozen
44
45 ``True`` if :meth:`freeze` was called, read-only property.
46
47 .. method:: freeze()
48
49 Freeze the list. After calling, any content modification is forbidden.
50
51 Installation
52 ------------
53
54 .. code-block:: bash
55
56 $ pip install aiosignal
57
58 The library requires Python 3.8 or newer.
59
60 Dependencies
61 ------------
62
63 aiosignal depends on the frozenlist_ library.
64
65 Documentation
66 =============
67
68 https://aiosignal.readthedocs.io/
69
70 Communication channels
71 ======================
72
73 *aio-libs discourse group*: https://aio-libs.discourse.group
74
75 Feel free to post your questions and ideas here.
76
77 *gitter chat* https://gitter.im/aio-libs/Lobby
78
79 Requirements
80 ============
81
82 - Python >= 3.8
83 - frozenlist >= 1.0.0
84
85 License
86 =======
87
88 ``aiosignal`` is offered under the Apache 2 license.
89
90 Source code
91 ===========
92
93 The project is hosted on GitHub_
94
95 Please file an issue in the `bug tracker
96 <https://github.com/aio-libs/aiosignal/issues>`_ if you have found a bug
97 or have some suggestions to improve the library.
98
99 Authors and License
100 ===================
101
102 The ``aiosignal`` package was originally part of the
103 :doc:`aiohttp project <aiohttp:index>`, written by Nikolay Kim and Andrew Svetlov.
104 It is now being maintained by Martijn Pieters.
105
106 It's *Apache 2* licensed and freely available.
107
108 Feel free to improve this package and send a pull request to GitHub_.
109
110
111 .. toctree::
112 :maxdepth: 2
113
114 Indices and tables
115 ==================
116
117 * :ref:`genindex`
118 * :ref:`search`
119
120
121 .. _GitHub: https://github.com/aio-libs/aiosignal
122 .. _frozenlist: https://github.com/aio-libs/frozenlist