getattr does not work for async DeviceProxy
I found that getattr does not work for async DeviceProxy. The reason is similar to the #561 (closed) : method does internal call of another DeviceProxy method, but in this time call just does not work:
import asyncio
from tango import get_device_proxy, GreenMode
from tango.server import Device, attribute
from tango.test_context import MultiDeviceTestContext
class TestDevice(Device):
@attribute()
def identity_attr(self) -> int:
return 1
async def main():
with MultiDeviceTestContext([{"class": TestDevice, "devices": [{"name": "test/test_device/1"}]}]):
dev = await get_device_proxy("test/test_device/1", green_mode=GreenMode.Asyncio)
await getattr(dev, "identity_attr")
if __name__ == "__main__":
asyncio.run(main())
ended with:
/home/matveyev/mambaforge/envs/pytango950/bin/python /home/matveyev/pytango/sandbox/server_for_tests_2.py
Can't create notifd event supplier. Notifd event not available
Traceback (most recent call last):
File "/home/matveyev/pytango/sandbox/server_for_tests_2.py", line 34, in <module>
asyncio.run(main())
File "/home/matveyev/mambaforge/envs/pytango950/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/home/matveyev/mambaforge/envs/pytango950/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matveyev/mambaforge/envs/pytango950/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/matveyev/pytango/sandbox/server_for_tests_2.py", line 31, in main
await getattr(dev, "identity_attr")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matveyev/pytango/tango/device_proxy.py", line 470, in __DeviceProxy__getattr
return __get_attribute_value(self, attr_info, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matveyev/pytango/tango/device_proxy.py", line 373, in __get_attribute_value
attr_value = self.read_attribute(name).value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_asyncio.Future' object has no attribute 'value'
Edited by Anton Joubert