Skip to content
Snippets Groups Projects
Commit 4b58b31d authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-391: Obtain proxies in separate thread because it may stall

parent 70b14840
No related branches found
No related tags found
No related merge requests found
...@@ -59,13 +59,7 @@ class DevicesInitialiser(Thread): ...@@ -59,13 +59,7 @@ class DevicesInitialiser(Thread):
def __init__(self, device_names, ignore_unavailable_devices=True, proxy_timeout=10.0): def __init__(self, device_names, ignore_unavailable_devices=True, proxy_timeout=10.0):
self.ignore_unavailable_devices = ignore_unavailable_devices self.ignore_unavailable_devices = ignore_unavailable_devices
# Since Python3.7+, the insertion order equals the iteration order, which is what we depend on self.device_names = device_names
# to process the devices in the same order as in device_names.
self.devices = {name: DeviceProxy(name) for name in device_names}
# set the timeout for all proxies
for device in self.devices.values():
device.set_timeout_millis(int(proxy_timeout * 1000))
# setup initial state # setup initial state
self.progress = 0 self.progress = 0
...@@ -77,7 +71,17 @@ class DevicesInitialiser(Thread): ...@@ -77,7 +71,17 @@ class DevicesInitialiser(Thread):
self.set_status("Starting initialisation") self.set_status("Starting initialisation")
try: try:
self.initialise_devices() # Since Python3.7+, the insertion order equals the iteration order, which is what we depend on
# to process the devices in the same order as in device_names.
self.devices = {}
for name in self.device_names:
self.set_status(f"Obtaining a DeviceProxy to {name}")
self.devices[name] = DeviceProxy(name)
# set the timeout for all proxies
for device in self.devices.values():
device.set_timeout_millis(int(proxy_timeout * 1000))
self.initialise_devices()
self.set_status("Initialisation completed") self.set_status("Initialisation completed")
except Exception as e: except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment