]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
chore: Use finally for cleanup 16457/head
authorJosh Soref <2119212+jsoref@users.noreply.github.com>
Sun, 9 Nov 2025 00:23:43 +0000 (19:23 -0500)
committerJosh Soref <2119212+jsoref@users.noreply.github.com>
Sun, 9 Nov 2025 00:28:15 +0000 (19:28 -0500)
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
regression-tests.recursor-dnssec/test_Protobuf.py

index 1d31e6c02546534f987f29cd229fdfd277ef75ef..857f27b8ebaced55c46ad01f0a90d5eeb82670f9 100644 (file)
@@ -46,19 +46,22 @@ def ProtobufListener(queue, port):
         sys.exit(1)
 
     sock.listen(100)
-    while True:
-        try:
-            (conn, _) = sock.accept()
-            thread = threading.Thread(name='Connection Handler',
-                                      target=ProtobufConnectionHandler,
-                                      args=[queue, conn])
-            thread.daemon = True
-            thread.start()
-
-        except socket.error as e:
-            print('Error in protobuf socket: %s' % str(e))
-
-    sock.close()
+
+    try:
+        while True:
+            try:
+                (conn, _) = sock.accept()
+                thread = threading.Thread(name='Connection Handler',
+                                        target=ProtobufConnectionHandler,
+                                        args=[queue, conn])
+                thread.daemon = True
+                thread.start()
+
+            except socket.error as e:
+                print('Error in protobuf socket: %s' % str(e))
+
+    finally:
+        sock.close()
 
 
 class ProtobufServerParams: