Skip to content

Commit 8aa32b7

Browse files
author
rodrigo.nogueira
committed
fix: add Windows cleanup delay in secure_proxy_url fixture
On Windows, proxy.py uses threaded mode which can leave sockets in a state where they haven't been fully released when GC runs during pytest cleanup. A short delay + explicit gc.collect() ensures the proxy threads finish cleanup before pytest's unraisableexception plugin collects warnings.
1 parent d10cd20 commit 8aa32b7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_proxy_functional.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def secure_proxy_url(tls_certificate_pem_path: str) -> Iterator[URL]:
8989
port=proxy_instance.flags.port,
9090
)
9191

92+
# On Windows, proxy.py uses threaded mode which can leave sockets in
93+
# a state where they haven't been fully released when GC runs during
94+
# pytest cleanup. A short delay + explicit gc.collect() ensures the
95+
# proxy threads finish cleanup before pytest's unraisableexception
96+
# plugin collects warnings.
97+
if os.name == "nt":
98+
import time
99+
import gc
100+
time.sleep(0.1)
101+
gc.collect()
92102

93103
@pytest.fixture
94104
def web_server_endpoint_payload() -> str:

0 commit comments

Comments
 (0)