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 4dd54a4e7e4..64f4598fed1 100644 --- a/aiohttp/__init__.py +++ b/aiohttp/__init__.py @@ -180,8 +180,6 @@ "AsyncResolver", "DefaultResolver", "ThreadedResolver", - # signals - "Signal", # streams "DataQueue", "EMPTY_PAYLOAD", diff --git a/docs/conf.py b/docs/conf.py index 7b3138ff1fa..67f71fe3aaa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -69,6 +69,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 f1a1ae96f55..00000000000 --- a/docs/signals.rst +++ /dev/null @@ -1,45 +0,0 @@ -.. currentmodule:: aiohttp - -Signals -======= - -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 8255df02f36..35e02a0d964 100644 --- a/docs/utilities.rst +++ b/docs/utilities.rst @@ -14,6 +14,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 2d1c3af1a7d..5ab08f946fc 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -1372,7 +1372,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, @@ -1385,7 +1385,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 @@ -1400,7 +1400,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. @@ -1420,7 +1420,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)