Ignore IPC in exception handler. Closes #262.

This commit is contained in:
Florian Bruhin 2014-11-30 22:30:26 +01:00
parent d558155620
commit 64e43c6e14
2 changed files with 9 additions and 0 deletions

View File

@ -498,6 +498,11 @@ class Application(QApplication):
log.destroy.exception("Error while getting objects") log.destroy.exception("Error while getting objects")
objects = "" objects = ""
try:
objreg.get('ipc-server').ignored = True
except Exception:
log.destroy.exception("Error while ignoring ipc")
try: try:
self.lastWindowClosed.disconnect(self.shutdown) self.lastWindowClosed.disconnect(self.shutdown)
except TypeError: except TypeError:

View File

@ -46,6 +46,7 @@ class IPCServer(QObject):
"""IPC server to which clients connect to. """IPC server to which clients connect to.
Attributes: Attributes:
ignored: Whether requests are ignored (in exception hook).
_timer: A timer to handle timeouts. _timer: A timer to handle timeouts.
_server: A QLocalServer to accept new connections. _server: A QLocalServer to accept new connections.
_socket: The QLocalSocket we're currently connected to. _socket: The QLocalSocket we're currently connected to.
@ -54,6 +55,7 @@ class IPCServer(QObject):
def __init__(self, parent=None): def __init__(self, parent=None):
"""Start the IPC server and listen to commands.""" """Start the IPC server and listen to commands."""
super().__init__(parent) super().__init__(parent)
self.ignored = False
self._remove_server() self._remove_server()
self._timer = usertypes.Timer(self, 'ipc-timeout') self._timer = usertypes.Timer(self, 'ipc-timeout')
self._timer.setInterval(READ_TIMEOUT) self._timer.setInterval(READ_TIMEOUT)
@ -86,6 +88,8 @@ class IPCServer(QObject):
@pyqtSlot() @pyqtSlot()
def handle_connection(self): def handle_connection(self):
"""Handle a new connection to the server.""" """Handle a new connection to the server."""
if self.ignored:
return
if self._socket is not None: if self._socket is not None:
log.ipc.debug("Got new connection but ignoring it because we're " log.ipc.debug("Got new connection but ignoring it because we're "
"still handling another one.") "still handling another one.")