diff --git a/CHANGES/6201.bugfix b/CHANGES/6201.bugfix new file mode 100644 index 00000000000..d09c2d5bbe8 --- /dev/null +++ b/CHANGES/6201.bugfix @@ -0,0 +1 @@ +Remove ``Signal`` from ``__all__``, replace ``aiohttp.Signal`` with ``aiosignal.Signal`` in docs diff --git a/aiohttp/__init__.py b/aiohttp/__init__.py index 46f9e76aeaf..9f5168b2965 100644 --- a/aiohttp/__init__.py +++ b/aiohttp/__init__.py @@ -183,8 +183,7 @@ "AsyncResolver", "DefaultResolver", "ThreadedResolver", - # signals - "Signal", + # streams "DataQueue", "EMPTY_PAYLOAD", "EofStream", diff --git a/docs/conf.py b/docs/conf.py index b37934aef54..d9dff86535f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,6 +70,7 @@ "python": ("http://docs.python.org/3", None), "multidict": ("https://multidict.readthedocs.io/en/stable/", None), "yarl": ("https://yarl.readthedocs.io/en/stable/", None), + "aiosignal": ("https://aiosignal.readthedocs.io/en/stable/", None), "aiohttpjinja2": ("https://aiohttp-jinja2.readthedocs.io/en/stable/", None), "aiohttpremotes": ("https://aiohttp-remotes.readthedocs.io/en/stable/", None), "aiohttpsession": ("https://aiohttp-session.readthedocs.io/en/stable/", None), diff --git a/docs/signals.rst b/docs/signals.rst deleted file mode 100644 index 1126c2ffc99..00000000000 --- a/docs/signals.rst +++ /dev/null @@ -1,45 +0,0 @@ -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 -` 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. diff --git a/docs/utilities.rst b/docs/utilities.rst index c328244224e..76d685d998e 100644 --- a/docs/utilities.rst +++ b/docs/utilities.rst @@ -15,6 +15,5 @@ Miscellaneous API Shared between Client And Server. multipart multipart_reference streams - signals structures websocket_utilities diff --git a/docs/web_reference.rst b/docs/web_reference.rst index 699eddf6030..ebe0f430f90 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -1407,7 +1407,7 @@ duplicated like one using :meth:`~aiohttp.web.Application.copy`. .. attribute:: on_response_prepare - A :class:`~aiohttp.Signal` that is fired near the end + A :class:`~aiosignal.Signal` that is fired near the end of :meth:`StreamResponse.prepare` with parameters *request* and *response*. It can be used, for example, to add custom headers to each response, or to modify the default headers computed by the application, @@ -1420,7 +1420,7 @@ duplicated like one using :meth:`~aiohttp.web.Application.copy`. .. attribute:: on_startup - A :class:`~aiohttp.Signal` that is fired on application start-up. + A :class:`~aiosignal.Signal` that is fired on application start-up. Subscribers may use the signal to run background tasks in the event loop along with the application's request handler just after the @@ -1435,7 +1435,7 @@ duplicated like one using :meth:`~aiohttp.web.Application.copy`. .. attribute:: on_shutdown - A :class:`~aiohttp.Signal` that is fired on application shutdown. + A :class:`~aiosignal.Signal` that is fired on application shutdown. Subscribers may use the signal for gracefully closing long running connections, e.g. websockets and data streaming. @@ -1455,7 +1455,7 @@ duplicated like one using :meth:`~aiohttp.web.Application.copy`. .. attribute:: on_cleanup - A :class:`~aiohttp.Signal` that is fired on application cleanup. + A :class:`~aiosignal.Signal` that is fired on application cleanup. Subscribers may use the signal for gracefully closing connections to database server etc. diff --git a/tests/test___all__.py b/tests/test___all__.py new file mode 100644 index 00000000000..d5e6445f9c8 --- /dev/null +++ b/tests/test___all__.py @@ -0,0 +1,24 @@ +from typing import Any + + +def test___all__(pytester: Any) -> None: + """ + See https://github.com/aio-libs/aiohttp/issues/6197 + """ + pytester.makepyfile( + test_a=""" + from aiohttp import * + """ + ) + result = pytester.runpytest("-vv") + result.assert_outcomes(passed=0, errors=0) + + +def test_web___all__(pytester: Any) -> None: + pytester.makepyfile( + test_b=""" + from aiohttp.web import * + """ + ) + result = pytester.runpytest("-vv") + result.assert_outcomes(passed=0, errors=0)