fix: remove idle timeout on gui
CI / lint (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / test-with-beamline-plugins (pxi_bec) (push) Skipped
CI / test-with-beamline-plugins (pxii_bec) (push) Skipped
CI / test-with-beamline-plugins (pxiii_bec) (push) Skipped
CI / lint (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / test-with-beamline-plugins (pxi_bec) (push) Skipped
CI / test-with-beamline-plugins (pxii_bec) (push) Skipped
CI / test-with-beamline-plugins (pxiii_bec) (push) Skipped
causing more problems than it fixed
This commit is contained in:
1 parent
d3c6c52abf
commit
c9d9d716ab
2 files changed
-99
No files matched your search
@@ -876,11 +876,6 @@ class MainWindow(QMainWindow):
|
||||
for locked_banner in self._locked_beamline_banners:
|
||||
locked_banner.installEventFilter(self)
|
||||
|
||||
self._idle_timer = QTimer(self)
|
||||
self._idle_timer.setInterval(60_000)
|
||||
self._idle_timer.timeout.connect(self._check_idle_timeout)
|
||||
self._idle_timer.start()
|
||||
|
||||
self._remote_close_timer = QTimer(self)
|
||||
self._remote_close_timer.setInterval(1000)
|
||||
self._remote_close_timer.timeout.connect(self._check_remote_close_deadline)
|
||||
@@ -3190,18 +3185,3 @@ class MainWindow(QMainWindow):
|
||||
|
||||
logger.warning("Closing GUI due to remote close request.")
|
||||
self.close()
|
||||
|
||||
@Slot()
|
||||
def _check_idle_timeout(self) -> None:
|
||||
idle_for_s = time.time() - self._last_user_interaction_ts
|
||||
if idle_for_s < self._idle_close_timeout_s:
|
||||
return
|
||||
|
||||
if not self._can_close_for_idle_or_remote():
|
||||
logger.info(
|
||||
"Idle timeout reached, but GUI remains open because beamline is busy or automation is active."
|
||||
)
|
||||
return
|
||||
# TODO deny communication from GUI to DAQ while IDLE for too long rather than kill the GUI
|
||||
logger.warning("Closing GUI after inactivity timeout.")
|
||||
self.close()
|
||||
@@ -352,85 +352,6 @@ def test_automation_activity_refreshes_idle_timestamp(qtbot, mock_ui_state):
|
||||
assert win._remote_close_deadline_ts is None
|
||||
|
||||
|
||||
def test_idle_timeout_closes_when_inactive_and_not_running(qtbot, mock_ui_state):
|
||||
with (
|
||||
patch("requests.get"),
|
||||
patch("aare.gui.main_window.DAQWorker"),
|
||||
patch("aare.gui.main_window.PredictionSubscriber"),
|
||||
patch("aare.gui.main_window.VideoThread"),
|
||||
patch("aare.gui.main_window.JFJochDBusClient"),
|
||||
patch("aare.gui.main_window.jwt.decode") as mock_jwt,
|
||||
):
|
||||
mock_jwt.return_value = {
|
||||
"sub": "testuser",
|
||||
"staff": True,
|
||||
"pgroups": ["p123"],
|
||||
"session": 15,
|
||||
}
|
||||
fake_token = "header.payload.signature"
|
||||
|
||||
win = MainWindow(
|
||||
base_url=None,
|
||||
token=fake_token,
|
||||
default_image=None,
|
||||
zmq_addr=None,
|
||||
pred_zmq_addr=None,
|
||||
beamline_cam_addr=None,
|
||||
gonio_cam_addr=None,
|
||||
gonio_cam_id=None,
|
||||
)
|
||||
qtbot.addWidget(win)
|
||||
|
||||
win._idle_close_timeout_s = 10
|
||||
win._last_user_interaction_ts = 100.0
|
||||
win.close = MagicMock()
|
||||
|
||||
with patch("aare.gui.main_window.time.time", return_value=111.0):
|
||||
win._check_idle_timeout()
|
||||
|
||||
win.close.assert_called_once()
|
||||
|
||||
|
||||
def test_idle_timeout_does_not_close_while_automation_active(qtbot, mock_ui_state):
|
||||
with (
|
||||
patch("requests.get"),
|
||||
patch("aare.gui.main_window.DAQWorker"),
|
||||
patch("aare.gui.main_window.PredictionSubscriber"),
|
||||
patch("aare.gui.main_window.VideoThread"),
|
||||
patch("aare.gui.main_window.JFJochDBusClient"),
|
||||
patch("aare.gui.main_window.jwt.decode") as mock_jwt,
|
||||
):
|
||||
mock_jwt.return_value = {
|
||||
"sub": "testuser",
|
||||
"staff": True,
|
||||
"pgroups": ["p123"],
|
||||
"session": 15,
|
||||
}
|
||||
fake_token = "header.payload.signature"
|
||||
|
||||
win = MainWindow(
|
||||
base_url=None,
|
||||
token=fake_token,
|
||||
default_image=None,
|
||||
zmq_addr=None,
|
||||
pred_zmq_addr=None,
|
||||
beamline_cam_addr=None,
|
||||
gonio_cam_addr=None,
|
||||
gonio_cam_id=None,
|
||||
)
|
||||
qtbot.addWidget(win)
|
||||
|
||||
win._idle_close_timeout_s = 10
|
||||
win._last_user_interaction_ts = 100.0
|
||||
win.job_list_panel.is_running = MagicMock(return_value=True)
|
||||
win.close = MagicMock()
|
||||
|
||||
with patch("aare.gui.main_window.time.time", return_value=111.0):
|
||||
win._check_idle_timeout()
|
||||
|
||||
win.close.assert_not_called()
|
||||
|
||||
|
||||
def _make_window(qtbot):
|
||||
win = MainWindow(
|
||||
base_url=None,
|
||||
|
||||
Reference in new issue
Block a user