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

Merge branch 'v0.31.0-fixes' into 'master'

Rollout fixes for v0.31.0

See merge request !887
parents d9be3c3e e5527286
No related branches found
No related tags found
1 merge request!887Rollout fixes for v0.31.0
...@@ -166,6 +166,7 @@ Next change the version in the following places: ...@@ -166,6 +166,7 @@ Next change the version in the following places:
# Release Notes # Release Notes
* 0.31.2 Bugfixes for v0.31.0 rollout, fixes race conditions when polling attributes
* 0.31.1 Add pre-push git hooks for basic CI checks * 0.31.1 Add pre-push git hooks for basic CI checks
* 0.31.0 Poll attributes independently from Tango * 0.31.0 Poll attributes independently from Tango
* 0.30.5 Log and count event subscription errors * 0.30.5 Log and count event subscription errors
......
0.31.1 0.31.2
...@@ -16,7 +16,7 @@ from pathlib import Path ...@@ -16,7 +16,7 @@ from pathlib import Path
from typing import List, Dict, Tuple from typing import List, Dict, Tuple
from functools import partial from functools import partial
from inspect import iscoroutinefunction from inspect import isawaitable
import numpy import numpy
from attribute_wrapper.attribute_wrapper import AttributeWrapper from attribute_wrapper.attribute_wrapper import AttributeWrapper
...@@ -784,10 +784,12 @@ class LOFARDevice(Device): ...@@ -784,10 +784,12 @@ class LOFARDevice(Device):
func = self._read_attribute(attr_name) func = self._read_attribute(attr_name)
if iscoroutinefunction(func): if isawaitable(func):
return asyncio.run(func()) return asyncio.run(func())
else: else:
return func() result = func()
return asyncio.run(result) if isawaitable(result) else result
async def async_read_attribute(self, attr_name): async def async_read_attribute(self, attr_name):
"""Read the value of a certain attribute (directly from the hardware). """Read the value of a certain attribute (directly from the hardware).
...@@ -797,10 +799,12 @@ class LOFARDevice(Device): ...@@ -797,10 +799,12 @@ class LOFARDevice(Device):
func = self._read_attribute(attr_name) func = self._read_attribute(attr_name)
if iscoroutinefunction(func): if isawaitable(func):
return await func() return await func()
else: else:
return func() result = func()
return await result if isawaitable(result) else result
def wait_attribute(self, attr_name, value, timeout=10, pollperiod=0.2): def wait_attribute(self, attr_name, value, timeout=10, pollperiod=0.2):
"""Wait until the given attribute obtains the given value. """Wait until the given attribute obtains the given value.
......
...@@ -173,7 +173,8 @@ class OPCUADevice(LOFARDevice): ...@@ -173,7 +173,8 @@ class OPCUADevice(LOFARDevice):
self.OPC_Time_Out, self.OPC_Time_Out,
self.Fault, self.Fault,
self.opcua_connection_status, self.opcua_connection_status,
event_loop=self.event_loop_thread.event_loop, # TODO(JDM): This results in a deadlock when polling attributes and mixing green/non-green functionality
# event_loop=self.event_loop_thread.event_loop,
device=self, device=self,
) )
self.opcua_connection.node_path_prefix = self.OPC_Node_Path_Prefix self.opcua_connection.node_path_prefix = self.OPC_Node_Path_Prefix
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment