diff --git a/electrum b/electrum index ff402a1c1..f9a4a26a3 100755 --- a/electrum +++ b/electrum @@ -313,22 +313,21 @@ if __name__ == '__main__': sys.exit(0) if cmdname == 'gui': - fd = daemon.get_fd_or_server(config) - if isinstance(fd, int): + fd, server = daemon.get_fd_or_server(config) + if fd is not None: d = daemon.Daemon(config, fd) d.start() d.init_gui(config, plugins) sys.exit(0) else: - server = fd result = server.gui(config_options) elif cmdname == 'daemon': subcommand = config.get('subcommand') assert subcommand in ['start', 'stop', 'status'] if subcommand == 'start': - fd = daemon.get_fd_or_server(config) - if isinstance(fd, int): + fd, server = daemon.get_fd_or_server(config) + if fd is not None: pid = os.fork() if pid: print_stderr("starting daemon (PID %d)" % pid) @@ -343,7 +342,6 @@ if __name__ == '__main__': d.join() sys.exit(0) else: - server = fd result = server.daemon(config_options) else: server = daemon.get_server(config) diff --git a/lib/daemon.py b/lib/daemon.py index cd219796e..b4c514ed8 100644 --- a/lib/daemon.py +++ b/lib/daemon.py @@ -48,12 +48,12 @@ def get_fd_or_server(config): lockfile = get_lockfile(config) while True: try: - return os.open(lockfile, os.O_CREAT | os.O_EXCL | os.O_WRONLY) + return os.open(lockfile, os.O_CREAT | os.O_EXCL | os.O_WRONLY), None except OSError: pass server = get_server(config) if server is not None: - return server + return None, server # Couldn't connect; remove lockfile and try again. remove_lockfile(lockfile)