# HG changeset patch # User RhodeCode Admin # Date 2023-01-20 12:19:04 # Node ID d9965ed62e52984edd105b05385a56738ad56f62 # Parent 2a635a31237f46624bd0a8d28183ec1faf30492a hooks: simplified code diff --git a/rhodecode/lib/hooks_daemon.py b/rhodecode/lib/hooks_daemon.py --- a/rhodecode/lib/hooks_daemon.py +++ b/rhodecode/lib/hooks_daemon.py @@ -153,13 +153,9 @@ class HttpHooksCallbackDaemon(ThreadedHo # request and wastes cpu at all other times. POLL_INTERVAL = 0.01 - def get_available_port(): - family = socket.AF_INET - socktype = socket.SOCK_STREAM - host = '127.0.0.1' - - mysocket = socket.socket(family, socktype) - mysocket.bind((host, 0)) + def get_available_port(self): + mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + mysocket.bind(('127.0.0.1', 0)) port = mysocket.getsockname()[1] mysocket.close() del mysocket