Browse Source

disambiguate types returned by get_fd_or_server

283
ThomasV 9 years ago
parent
commit
ddc1869551
  1. 10
      electrum
  2. 4
      lib/daemon.py

10
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)

4
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)

Loading…
Cancel
Save