Skip to content

Commit d743057

Browse files
SNOW-3244317: Fix pytest session hang caused by pytest-rerunfailures socket server (#2807)
1 parent f3d7434 commit d743057

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

DESCRIPTION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ https://docs.snowflake.com/
77
Source code is also available at: https://github.com/snowflakedb/snowflake-connector-python
88

99
# Release Notes
10-
- v4.4.0(March 23,2026)
10+
- v4.4.0(March 24,2026)
1111
- Bump lower boundary of cryptography to 46.0.5 due to CVE-2026-26007.
1212
- Added support for Python 3.14.
1313
- Removed pyOpenSSL upper bound dependency constraint to allow installation of pyOpenSSL 26.0.0+, which includes a fix for GHSA-vp96-hxj8-p424.

test/conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import annotations
33

44
import os
5+
import socket
56
from contextlib import contextmanager
67
from logging import getLogger
78
from pathlib import Path
@@ -157,6 +158,27 @@ def pytest_runtest_setup(item) -> None:
157158
pytest.skip("Skipping WIF test in current environment")
158159

159160

161+
def pytest_unconfigure(config) -> None:
162+
"""Shut down the pytest-rerunfailures socket server to prevent session hangs.
163+
164+
The ServerStatusDB.run_server thread blocks forever on socket.accept()
165+
with no shutdown mechanism. Closing the socket here unblocks it so the
166+
interpreter can exit cleanly instead of deadlocking during teardown.
167+
See: https://github.com/pytest-dev/pytest-rerunfailures/issues/295
168+
"""
169+
db = getattr(config, "failures_db", None)
170+
sock = getattr(db, "sock", None)
171+
if sock is not None:
172+
try:
173+
sock.shutdown(socket.SHUT_RDWR)
174+
except OSError:
175+
pass
176+
try:
177+
sock.close()
178+
except OSError:
179+
pass
180+
181+
160182
def get_server_parameter_value(connection, parameter_name: str) -> str | None:
161183
"""Get server parameter value, returns None if parameter doesn't exist."""
162184
try:

0 commit comments

Comments
 (0)