ipc: Simplify exception handling.
This commit is contained in:
parent
ea0cbea1dd
commit
9b1d0af20d
@ -354,27 +354,24 @@ def send_or_listen(args):
|
|||||||
"""
|
"""
|
||||||
socketname = _get_socketname(args.basedir)
|
socketname = _get_socketname(args.basedir)
|
||||||
try:
|
try:
|
||||||
sent = send_to_running_instance(socketname, args.command)
|
|
||||||
if sent:
|
|
||||||
return None
|
|
||||||
log.init.debug("Starting IPC server...")
|
|
||||||
server = IPCServer(_get_socketname(args.basedir))
|
|
||||||
server.listen()
|
|
||||||
objreg.register('ipc-server', server)
|
|
||||||
return server
|
|
||||||
except AddressInUseError as e:
|
|
||||||
# This could be a race condition...
|
|
||||||
log.init.debug("Got AddressInUseError, trying again.")
|
|
||||||
time.sleep(0.5)
|
|
||||||
try:
|
try:
|
||||||
|
sent = send_to_running_instance(socketname, args.command)
|
||||||
|
if sent:
|
||||||
|
return None
|
||||||
|
log.init.debug("Starting IPC server...")
|
||||||
|
server = IPCServer(_get_socketname(args.basedir))
|
||||||
|
server.listen()
|
||||||
|
objreg.register('ipc-server', server)
|
||||||
|
return server
|
||||||
|
except AddressInUseError as e:
|
||||||
|
# This could be a race condition...
|
||||||
|
log.init.debug("Got AddressInUseError, trying again.")
|
||||||
|
time.sleep(0.5)
|
||||||
sent = send_to_running_instance(socketname, args.command)
|
sent = send_to_running_instance(socketname, args.command)
|
||||||
if sent:
|
if sent:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
raise e
|
raise
|
||||||
except Error as e:
|
|
||||||
display_error(e, args)
|
|
||||||
raise
|
|
||||||
except Error as e:
|
except Error as e:
|
||||||
display_error(e, args)
|
display_error(e, args)
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user