From bcd2e594f0d94c833cc28c173ee48544cacb06e5 Mon Sep 17 00:00:00 2001 From: Chris Guidry Date: Fri, 5 Dec 2025 12:03:05 -0500 Subject: [PATCH] Use SelectorEventLoop on Windows to fix pytest crashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows ProactorEventLoop has known memory corruption issues that cause pytest-xdist worker crashes with "node down: Not properly terminated". Setting WindowsSelectorEventLoopPolicy in conftest.py avoids this issue. See: https://github.com/python/cpython/issues/116773 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 22487f97e..b45824a9e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,6 @@ +import asyncio import socket +import sys from collections.abc import Callable from pathlib import Path from typing import Any @@ -7,6 +9,11 @@ import pytest from fastmcp.utilities.tests import temporary_settings +# Use SelectorEventLoop on Windows to avoid ProactorEventLoop crashes +# See: https://github.com/python/cpython/issues/116773 +if sys.platform == "win32": + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + def pytest_collection_modifyitems(items): """Automatically mark tests in integration_tests folder with 'integration' marker."""