Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions tests/shutdown_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import socket
import sys
import threading
import time
from types import FunctionType

import wreq
Expand All @@ -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")


Expand Down
Loading