From 52d57658d41b8d6c561f50c675cb6154c5c9a27a Mon Sep 17 00:00:00 2001
From: David Brochart <david.brochart@gmail.com>
Date: Sat, 8 Mar 2025 10:19:19 +0100
Subject: [PATCH] Check if socket already closed

---
 tests/conftest.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/conftest.py b/tests/conftest.py
index ac75fb1..8f68ac6 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,6 +1,5 @@
 import os
 import signal
-import socket
 from threading import Thread
 
 import zmq
@@ -76,7 +75,8 @@ def sockets(contexts):
 
     # close sockets
     for socket in sockets:
-        socket.close(linger=0)
+        if not socket.closed:
+            socket.close(linger=0)
 
 
 @pytest.fixture
