From 2064a48fc5987739725fc123f7a50ea906cb0579 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Tue, 19 Nov 2024 11:14:32 +0100 Subject: [PATCH] Set asyncio WindowsSelectorEventLoopPolicy on Windows --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index db992b747..49e38c7c0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,6 @@ +import asyncio import logging +import os from math import inf from threading import Event from typing import Any, Callable, no_type_check @@ -40,6 +42,11 @@ resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) +# Enforce selector event loop on Windows. +if os.name == "nt": + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type:ignore + + class TestSession(Session): """A session that copies sent messages to an internal stream, so that they can be accessed later.