From 9b1d0af20d9d8647ce0c99c97733584cc3aaa58a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 4 Sep 2015 07:16:16 +0200 Subject: [PATCH] ipc: Simplify exception handling. --- qutebrowser/misc/ipc.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index e2b2e0cd1..49c5e1d7a 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -354,27 +354,24 @@ def send_or_listen(args): """ socketname = _get_socketname(args.basedir) 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: + 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) if sent: return None else: - raise e - except Error as e: - display_error(e, args) - raise + raise except Error as e: display_error(e, args) raise