File size: 2,628 Bytes
065fee7 |
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
aiosignal
=========
A project to manage callbacks in `asyncio` projects.
``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 you call ``sig.freeze()`` the signal is *frozen*: adding, removing
and dropping callbacks is forbidden.
The only available operation is calling the previously registered
callbacks by using ``await sig.send(data)``.
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>`.
API
---
.. class:: aiosignal.Signal(owner)
The signal, implements the :class:`collections.abc.MutableSequence`
interface. The *owner* object is shown in the signal representation,
and is there to make debugging easier.
.. method:: send(*args, **kwargs)
:async:
Call all registered callbacks one by one starting from the beginning
of the list.
.. attribute:: frozen
``True`` if :meth:`freeze` was called, read-only property.
.. method:: freeze()
Freeze the list. After calling, any content modification is forbidden.
Installation
------------
.. code-block:: bash
$ pip install aiosignal
The library requires Python 3.6 or newer.
Dependencies
------------
aiosignal depends on the frozenlist_ library.
Documentation
=============
https://aiosignal.readthedocs.io/
Communication channels
======================
*aio-libs discourse group*: https://aio-libs.discourse.group
Feel free to post your questions and ideas here.
*gitter chat* https://gitter.im/aio-libs/Lobby
Requirements
============
- Python >= 3.6
- frozenlist >= 1.0.0
License
=======
``aiosignal`` is offered under the Apache 2 license.
Source code
===========
The project is hosted on GitHub_
Please file an issue in the `bug tracker
<https://github.com/aio-libs/aiosignal/issues>`_ if you have found a bug
or have some suggestions to improve the library.
Authors and License
===================
The ``aiosignal`` package was originally part of the
:doc:`aiohttp project <aiohttp:index>`, written by Nikolay Kim and Andrew Svetlov.
It is now being maintained by Martijn Pieters.
It's *Apache 2* licensed and freely available.
Feel free to improve this package and send a pull request to GitHub_.
.. toctree::
:maxdepth: 2
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`
.. _GitHub: https://github.com/aio-libs/aiosignal
.. _frozenlist: https://github.com/aio-libs/frozenlist
|