Skip to content

Commit

Permalink
Remove tokio support (#7281)
Browse files Browse the repository at this point in the history
Project has been archived and was last updated 6 years ago. It's dead.
  • Loading branch information
Dreamsorcerer authored May 13, 2023
1 parent b2a7983 commit 0761da6
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 43 deletions.
3 changes: 0 additions & 3 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ ignore_missing_imports = True
[mypy-gunicorn.*]
ignore_missing_imports = True

[mypy-tokio]
ignore_missing_imports = True

[mypy-uvloop]
ignore_missing_imports = True

Expand Down
1 change: 1 addition & 0 deletions CHANGES/7281.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed support for unsupported ``tokio`` event loop -- by :user:`Dreamsorcerer`
12 changes: 2 additions & 10 deletions aiohttp/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,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]]


Expand All @@ -43,7 +38,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",
Expand Down Expand Up @@ -203,11 +198,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(","):
Expand Down
14 changes: 1 addition & 13 deletions aiohttp/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -243,15 +243,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

# 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()
7 changes: 0 additions & 7 deletions tests/test_run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,13 @@
HAS_IPV6 = False


# tokio event loop does not allow to override attributes
def skip_if_no_dict(loop: Any) -> None:
if not hasattr(loop, "__dict__"):
pytest.skip("can not override loop attributes")


def skip_if_on_windows() -> None:
if platform.system() == "Windows":
pytest.skip("the test is not valid for Windows")


@pytest.fixture
def patched_loop(loop: Any):
skip_if_no_dict(loop)
server = mock.Mock()
server.wait_closed = make_mocked_coro(None)
loop.create_server = make_mocked_coro(server)
Expand Down
10 changes: 0 additions & 10 deletions tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,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 = {}
Expand Down Expand Up @@ -200,8 +194,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()
Expand All @@ -221,8 +213,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()
Expand Down

0 comments on commit 0761da6

Please sign in to comment.