Asyncio dynamic commands do not work
I found, that if ine uses asyn method for dynamic command, then is does not work, since method is never awaited:
from tango import GreenMode
from tango.server import Device, command
from tango.test_context import DeviceTestContext
class TestDevice(Device):
green_mode = GreenMode.Asyncio
async def init_device(self):
await super().init_device()
cmd = command(self.identity, dtype_in=int, dtype_out=int)
self.add_command(cmd)
async def identity(self, arg):
return arg
if __name__ == "__main__":
with DeviceTestContext(TestDevice) as proxy:
print(proxy.identity(123))
results in
/home/matveyev/mambaforge/envs/pytangodev_10/bin/python /home/matveyev/pytango/sandbox/server_for_tests.py
Can't create notifd event supplier. Notifd event not available
/home/matveyev/pytango/tango/connection.py:145: RuntimeWarning: coroutine 'TestDevice.identity' was never awaited
return self.__command_inout(cmd_name, param)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
omniORB: (0) 2023-12-12 14:43:51.084810: Warning: method 'command_inout_4' raised an unknown exception (not a legal CORBA exception).
Traceback (most recent call last):
File "/home/matveyev/pytango/sandbox/server_for_tests.py", line 31, in <module>
print(proxy.identity(123))
File "/home/matveyev/pytango/tango/device_proxy.py", line 365, in f
return dp.command_inout(name, *args, **kwds)
File "/home/matveyev/pytango/tango/green.py", line 234, in greener
return executor.run(fn, args, kwargs, wait=wait, timeout=timeout)
File "/home/matveyev/pytango/tango/green.py", line 124, in run
return fn(*args, **kwargs)
File "/home/matveyev/pytango/tango/connection.py", line 116, in __Connection__command_inout
r = Connection.command_inout_raw(self, name, *args, **kwds)
File "/home/matveyev/pytango/tango/connection.py", line 145, in __Connection__command_inout_raw
return self.__command_inout(cmd_name, param)
PyTango.CommunicationFailed: DevFailed[
DevError[
desc = UNKNOWN CORBA system exception
origin = virtual Tango::DeviceData Tango::Connection::command_inout(const std::string&, const Tango::DeviceData&) at (/home/conda/feedstock_root/build_artifacts/cpptango_1696935985347/work/src/client/devapi_base.cpp:1378)
reason = API_CorbaException
severity = ERR]
DevError[
desc = Failed to execute command_inout on device test/nodb/testdevice, command identity
origin = virtual Tango::DeviceData Tango::Connection::command_inout(const std::string&, const Tango::DeviceData&) at (/home/conda/feedstock_root/build_artifacts/cpptango_1696935985347/work/src/client/devapi_base.cpp:1378)
reason = API_CommunicationFailed
severity = ERR]
]
Ready to accept request
Process finished with exit code 1
Edited by Yury Matveyev