diff options
Diffstat (limited to 'qutebrowser/misc/ipc.py')
-rw-r--r-- | qutebrowser/misc/ipc.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index 34c31ec4a..86f0422f3 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -356,32 +356,38 @@ class IPCServer(QObject): self.got_args.emit(args, target_arg, cwd) - @pyqtSlot() - def on_ready_read(self): - """Read json data from the client.""" + def _get_socket(self): + """Get the current socket for on_ready_read.""" if self._socket is None: # pragma: no cover # This happens when doing a connection while another one is already # active for some reason. if self._old_socket is None: - log.ipc.warning("In on_ready_read with None socket and " - "old_socket!") - return - log.ipc.debug("In on_ready_read with None socket!") + log.ipc.warning("In _get_socket with None socket and old_socket!") + return None + log.ipc.debug("In _get_socket with None socket!") socket = self._old_socket else: socket = self._socket if sip.isdeleted(socket): # pragma: no cover log.ipc.warning("Ignoring deleted IPC socket") - return + return None + return socket + + @pyqtSlot() + def on_ready_read(self): + """Read json data from the client.""" self._timer.stop() + + socket = self._get_socket() while socket is not None and socket.canReadLine(): data = bytes(socket.readLine()) self.got_raw.emit(data) log.ipc.debug("Read from socket 0x{:x}: {!r}".format( id(socket), data)) self._handle_data(data) + socket = self._get_socket() if self._socket is not None: self._timer.start() |