From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:23:43 +0000 (-0500) Subject: chore: Use finally for cleanup X-Git-Tag: rec-5.4.0-alpha1~116^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac61a8616b89ae9aa4f9fa927c7be659a19901b5;p=thirdparty%2Fpdns.git chore: Use finally for cleanup Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com> --- diff --git a/regression-tests.recursor-dnssec/test_Protobuf.py b/regression-tests.recursor-dnssec/test_Protobuf.py index 1d31e6c025..857f27b8eb 100644 --- a/regression-tests.recursor-dnssec/test_Protobuf.py +++ b/regression-tests.recursor-dnssec/test_Protobuf.py @@ -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: