diff --git a/.mypy.ini b/.mypy.ini index 1bfc5dcbf61..56923fd9fd8 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -39,9 +39,6 @@ ignore_missing_imports = True [mypy-gunicorn.*] ignore_missing_imports = True -[mypy-tokio] -ignore_missing_imports = True - [mypy-uvloop] ignore_missing_imports = True diff --git a/CHANGES/7281.removal b/CHANGES/7281.removal new file mode 100644 index 00000000000..ddbf457b175 --- /dev/null +++ b/CHANGES/7281.removal @@ -0,0 +1 @@ +Removed support for unsupported ``tokio`` event loop -- by :user:`Dreamsorcerer` diff --git a/aiohttp/pytest_plugin.py b/aiohttp/pytest_plugin.py index 333dad25af5..23286a98aec 100644 --- a/aiohttp/pytest_plugin.py +++ b/aiohttp/pytest_plugin.py @@ -25,11 +25,6 @@ except ImportError: # pragma: no cover uvloop = None -try: - import tokio -except ImportError: # pragma: no cover - tokio = None - AiohttpClient = Callable[[Union[Application, BaseTestServer]], Awaitable[TestClient]] @@ -44,7 +39,7 @@ def pytest_addoption(parser): # type: ignore[no-untyped-def] "--aiohttp-loop", action="store", default="pyloop", - help="run tests with specific loop: pyloop, uvloop, tokio or all", + help="run tests with specific loop: pyloop, uvloop or all", ) parser.addoption( "--aiohttp-enable-loop-debug", @@ -198,11 +193,8 @@ def pytest_generate_tests(metafunc): # type: ignore[no-untyped-def] if uvloop is not None: # pragma: no cover avail_factories["uvloop"] = uvloop.EventLoopPolicy - if tokio is not None: # pragma: no cover - avail_factories["tokio"] = tokio.EventLoopPolicy - if loops == "all": - loops = "pyloop,uvloop?,tokio?" + loops = "pyloop,uvloop?" factories = {} # type: ignore[var-annotated] for name in loops.split(","): diff --git a/aiohttp/worker.py b/aiohttp/worker.py index f1302899f2f..512b483fad5 100644 --- a/aiohttp/worker.py +++ b/aiohttp/worker.py @@ -26,7 +26,7 @@ SSLContext = object # type: ignore[misc,assignment] -__all__ = ("GunicornWebWorker", "GunicornUVLoopWebWorker", "GunicornTokioWebWorker") +__all__ = ("GunicornWebWorker", "GunicornUVLoopWebWorker") class GunicornWebWorker(base.Worker): # type: ignore[misc,no-any-unimported] @@ -251,19 +251,3 @@ def init_process(self) -> None: asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) super().init_process() - - -class GunicornTokioWebWorker(GunicornWebWorker): - def init_process(self) -> None: # pragma: no cover - import tokio - - # Close any existing event loop before setting a - # new policy. - asyncio.get_event_loop().close() - - # Setup tokio policy, so that every - # asyncio.get_event_loop() will create an instance - # of tokio event loop. - asyncio.set_event_loop_policy(tokio.EventLoopPolicy()) - - super().init_process() diff --git a/tests/test_run_app.py b/tests/test_run_app.py index dbe1eefdcf3..29b08e33928 100644 --- a/tests/test_run_app.py +++ b/tests/test_run_app.py @@ -51,12 +51,6 @@ HAS_IPV6 = False -# tokio event loop does not allow to override attributes -def skip_if_no_dict(loop): - if not hasattr(loop, "__dict__"): - pytest.skip("can not override loop attributes") - - def skip_if_on_windows(): if platform.system() == "Windows": pytest.skip("the test is not valid for Windows") @@ -64,7 +58,6 @@ def skip_if_on_windows(): @pytest.fixture def patched_loop(loop): - skip_if_no_dict(loop) server = mock.Mock() server.wait_closed = make_mocked_coro(None) loop.create_server = make_mocked_coro(server) diff --git a/tests/test_worker.py b/tests/test_worker.py index 2e8b2c45d7e..4023f214059 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -22,12 +22,6 @@ ACCEPTABLE_LOG_FORMAT = '%a "%{Referrer}i" %s' -# tokio event loop does not allow to override attributes -def skip_if_no_dict(loop): - if not hasattr(loop, "__dict__"): - pytest.skip("can not override loop attributes") - - class BaseTestWorker: def __init__(self): self.servers = {} @@ -202,8 +196,6 @@ def test__get_valid_log_format_exc(worker) -> None: async def test__run_ok_parent_changed(worker, loop, aiohttp_unused_port) -> None: - skip_if_no_dict(loop) - worker.ppid = 0 worker.alive = True sock = socket.socket() @@ -223,8 +215,6 @@ async def test__run_ok_parent_changed(worker, loop, aiohttp_unused_port) -> None async def test__run_exc(worker, loop, aiohttp_unused_port) -> None: - skip_if_no_dict(loop) - worker.ppid = os.getppid() worker.alive = True sock = socket.socket()