Skip to content

Commit

Permalink
timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed May 6, 2024
1 parent f9ae555 commit 245d117
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions qutebrowser/misc/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import time
import functools
import json
import getpass
import binascii
Expand Down Expand Up @@ -154,7 +155,7 @@ def __init__(self, socket: QLocalSocket, parent: Optional[QObject] = None):

self._timer = usertypes.Timer(self, "ipc-timeout")
self._timer.setInterval(READ_TIMEOUT)
self._timer.timeout.connect(self.on_timeout)
self._timer.timeout.connect(functools.partial(self.on_timeout, time.time()))
self._timer.start()

self._socket: Optional[QLocalSocket] = socket
Expand Down Expand Up @@ -219,11 +220,11 @@ def on_ready_read(self) -> None:
if self._socket is not None:
self._timer.start()

@pyqtSlot()
def on_timeout(self) -> None:
@pyqtSlot(float)
def on_timeout(self, t: float) -> None:
"""Cancel the current connection if it was idle for too long."""
assert self._socket is not None
log.ipc.error(f"IPC connection timed out (socket {self.conn_id}).")
log.ipc.error(f"IPC connection timed out (socket {self.conn_id}, t {t}, now {time.time()}).")
self._socket.disconnectFromServer()
if self._socket is not None: # pragma: no cover
# on_disconnected sets it to None
Expand Down

0 comments on commit 245d117

Please sign in to comment.