diff --git a/src/fastmcp/utilities/tests.py b/src/fastmcp/utilities/tests.py index 1a4a12b05..6b7b28194 100644 --- a/src/fastmcp/utilities/tests.py +++ b/src/fastmcp/utilities/tests.py @@ -34,6 +34,7 @@ async def _wait_for_port( interval: Time between connection attempts """ import asyncio + import sys start = asyncio.get_running_loop().time() while True: @@ -42,7 +43,10 @@ async def _wait_for_port( asyncio.open_connection(host, port), timeout=interval ) writer.close() - await writer.wait_closed() + # On Windows, wait_closed() can hang due to ProactorEventLoop socket + # shutdown issues. Skip it - the socket will be cleaned up eventually. + if sys.platform != "win32": + await writer.wait_closed() return except (OSError, asyncio.TimeoutError): if asyncio.get_running_loop().time() - start > timeout: diff --git a/tests/conftest.py b/tests/conftest.py index 7c524b5ee..22487f97e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,26 +2,12 @@ import socket from collections.abc import Callable from pathlib import Path from typing import Any -from unittest.mock import patch import pytest from fastmcp.utilities.tests import temporary_settings -# Fakeredis connection pool disconnect can hang on Windows due to ProactorEventLoop -# socket shutdown issues. Since fakeredis uses in-memory connections that don't need -# proper network cleanup, we skip the disconnect entirely in tests. -async def _fast_disconnect(self): - pass - - -_disconnect_patch = patch( - "redis.asyncio.connection.ConnectionPool.disconnect", _fast_disconnect -) -_disconnect_patch.start() - - def pytest_collection_modifyitems(items): """Automatically mark tests in integration_tests folder with 'integration' marker.""" for item in items: