Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

test: skip redis connection pool disconnect to fix Windows hangs

Chris Guidry0d96f88d5917
diff --git a/tests/conftest.py b/tests/conftest.py
index 22487f97e..7c524b5ee 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2,12 +2,26 @@ 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: