Commit 17880886 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch '2475-lima-prepare_timeout-does-not-appear-to-be-used' into 'master'

Resolve "lima prepare_timeout does not appear to be used"

Closes #2475

See merge request !3888
parents 627385a5 0512b2ad
Pipeline #51710 passed with stages
in 148 minutes and 22 seconds
...@@ -74,8 +74,8 @@ class ChangeTangoTimeout(object): ...@@ -74,8 +74,8 @@ class ChangeTangoTimeout(object):
self.__device = device self.__device = device
def __enter__(self): def __enter__(self):
self.__back_timeout = self.__device.get_timeout_millis() self.__back_timeout = int(self.__device.get_timeout_millis())
self.__device.set_timeout_millis(1000 * self.__timeout) self.__device.set_timeout_millis(int(1000 * self.__timeout))
def __exit__(self, type_, value, traceback): def __exit__(self, type_, value, traceback):
self.__device.set_timeout_millis(self.__back_timeout) self.__device.set_timeout_millis(self.__back_timeout)
......
...@@ -468,6 +468,7 @@ def start_tango_server(*cmdline_args, **kwargs): ...@@ -468,6 +468,7 @@ def start_tango_server(*cmdline_args, **kwargs):
raise RuntimeError(f"could not start {device_fqdn}") from exception raise RuntimeError(f"could not start {device_fqdn}") from exception
try: try:
dev_proxy.server_pid = p.pid
yield dev_proxy yield dev_proxy
finally: finally:
wait_terminate(p) wait_terminate(p)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# Distributed under the GNU LGPLv3. See LICENSE for more info. # Distributed under the GNU LGPLv3. See LICENSE for more info.
import os import os
import signal
import time import time
import types import types
import pytest import pytest
...@@ -1514,3 +1515,43 @@ def test_roi_collection(default_session, lima_simulator, tmp_path): ...@@ -1514,3 +1515,43 @@ def test_roi_collection(default_session, lima_simulator, tmp_path):
* (roisize[0] * roisize[1]) * (roisize[0] * roisize[1])
* numpy.arange(1, roinums[0] * roinums[1] + 1) * numpy.arange(1, roinums[0] * roinums[1] + 1)
) )
def test_prepare_timeout(default_session):
cfg = default_session.config.get_config("lima_simulator")
cfg["prepare_timeout"] = 0.1
with lima_simulator_context(
"simulator", "id00/limaccds/simulator1"
) as lima_simulator:
dev_fqdn, lima_proxy = lima_simulator
cam = default_session.config.get("lima_simulator")
reset_cam(cam)
# check it receives the correct value from config
assert cam._Lima__prepare_timeout == 0.1
with pytest.raises(DevFailed) as exc_info:
os.kill(lima_proxy.server_pid, signal.SIGSTOP) # the server won't answer
cam.prepareAcq()
assert "Timedout" in str(exc_info.value)
# check it works if prepare_timeout > prepare time
del default_session.config._name2instance["lima_simulator"]
cfg = default_session.config.get_config("lima_simulator")
cfg["prepare_timeout"] = 1
with lima_simulator_context(
"simulator", "id00/limaccds/simulator1"
) as lima_simulator:
dev_fqdn, lima_proxy = lima_simulator
cam = default_session.config.get("lima_simulator")
reset_cam(cam)
# check it receives the correct value from config
assert cam._Lima__prepare_timeout == 1
os.kill(lima_proxy.server_pid, signal.SIGSTOP) # the server won't answer
prepare_task = gevent.spawn(cam.prepareAcq)
gevent.sleep(0.5)
os.kill(lima_proxy.server_pid, signal.SIGCONT) # server runs again
prepare_task.get()
assert prepare_task.successful()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment