commit ddc1869551aa42f4e65da72700bc91e90beaf873
parent 690c8629239b8eb615f52613cc850ec8ab02d4e9
Author: ThomasV <thomasv@electrum.org>
Date: Mon, 1 Feb 2016 13:10:01 +0100
disambiguate types returned by get_fd_or_server
Diffstat:
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git 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
@@ -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)