From 7641137ecc161ec15e5adf6d458ca42ed774f79e Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 19 Nov 2015 11:05:49 +0100 Subject: [PATCH] simplify get_daemon --- electrum | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/electrum b/electrum index 67de37721..fbb5fd578 100755 --- a/electrum +++ b/electrum @@ -369,29 +369,17 @@ class NetworkServer(util.DaemonThread): print_error("Daemon exiting") - - -def get_daemon(config, start_daemon): +def get_daemon(config): daemon_socket = os.path.join(config.path, DAEMON_SOCKET) - daemon_started = False - while True: - try: - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect(daemon_socket) - return s - except socket.error: - if not start_daemon: - return False - elif not daemon_started: - daemon_started = True - else: - time.sleep(0.1) - except: - # do not use daemon if AF_UNIX is not available (windows) - return False - - - + try: + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.connect(daemon_socket) + return s + except socket.error: + return False + except: + # do not use daemon if AF_UNIX is not available (windows) + return False @@ -472,7 +460,7 @@ if __name__ == '__main__': config_options['password'] = password # check if daemon is running - s = get_daemon(config, False) + s = get_daemon(config) if s: p = util.SocketPipe(s) p.set_timeout(1000000)