From a1f019f1da5f21070b672d3e9a824e717322d27d Mon Sep 17 00:00:00 2001 From: 0x676e67 Date: Tue, 3 Nov 2026 15:08:38 +0000 Subject: [PATCH] fix(test): avoid lock waits during finalization on Python 3.15 --- tests/shutdown_test.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/shutdown_test.py b/tests/shutdown_test.py index 54efdc1a..e5aa6840 100644 --- a/tests/shutdown_test.py +++ b/tests/shutdown_test.py @@ -11,7 +11,7 @@ import os import socket import sys -import threading +import time from types import FunctionType import wreq @@ -23,19 +23,16 @@ url = f"http://127.0.0.1:{listener.getsockname()[1]}/" -wait_lock = threading.Lock() -wait_lock.acquire() - - class HoldTeardown: def __init__(self, peer, task): self.peer = peer self.task = task - def __del__(self, write=os.write, wait=wait_lock.acquire): + # Sleep rather than wait on a lock: Python 3.15 refuses locks during finalization. + def __del__(self, write=os.write, wait=time.sleep): self.peer.close() write(2, b"teardown: connection closed\\n") - wait(timeout=1) + wait(1) write(2, b"teardown: wait complete\\n")