Asynchronous command callback

Dear all,

I am currently running PyTango 8.1.1 (default in Ubuntu 14.04 LTS). The PyTango API for v8 specifics the following DeviceProxy call:

command_inout_asynch( self, cmd_name, cmd_param, callback) -> None

which should trigger a callback function when the command has executed. However, this call does not seem available:


Traceback (most recent call last):
File "/home/andrea/Documents/AAVS/aavs-tango/devices_new/TPM_DS_Test.py", line 43, in <module>
tpm.command_inout_asynch("download_firmware", argin, callback=general_callback)
TypeError: __Connection__command_inout_asynch() got an unexpected keyword argument 'callback'

In fact, the only async method there seems to be available is:
def command_inout_asynch(self, cmd_name, cmd_param=None, forget=False)

Am I doing anything wrong? What can I do to get this functionality (please not I can't use PyTango9 for this project).

Thanks,
Andrea
Dr Andrea DeMarco, BSc (Hons) (Melita), MSc (Melita), DPhil (UEA)
Lecturer | Researcher
Department of Physics
Institute of Space Sciences and Astronomy

Room 220, Maths and Physics Building
University of Malta, Msida MSD2080, MALTA
It works for me on PyTango 8.1.8, but you have to enable the PUSH_CALLBACK submodel, and you cannot use keyword arguments for some reason.


>>> apiutil = PyTango.ApiUtil.instance()
>>> apiutil.set_asynch_cb_sub_model(PyTango.cb_sub_model.PUSH_CALLBACK)
>>> def callback(arg): print(arg)
>>> device = DeviceProxy('a/b/c')
>>> device.command_inout_asynch('Status', callback)
>>> 
<PyTango._PyTango.CmdDoneEvent object at 0x2283440>
Hi Vincent,

Thanks for your help. I am still on 8.1.1, and it looks like it could work….except I get this error:
terminate called after throwing an instance of 'boost::python::error_already_set'

This error happens a few seconds after the async call is made, and from my debug log I can see that the call has started. But before the call ends (which it eventually seems to do from the device server debug stream, which keeps showing the call is working), I get the error above in my client (which has terminated).

Any clues?

EDIT: I have now installed PyTango 8.1.8, and I still get the same error as above.
EDIT 2: This seems to be an open bug in PyTango:
https://sourceforge.net/p/tango-cs/bugs/719/

EDIT 3: Indeed, everything works if the callback has an argument e.g.
def general_callback(arg):
    print "Callback called!"

rather than:
def general_callback():
    print "Callback called!"
Thanks,
Andrea
Dr Andrea DeMarco, BSc (Hons) (Melita), MSc (Melita), DPhil (UEA)
Lecturer | Researcher
Department of Physics
Institute of Space Sciences and Astronomy

Room 220, Maths and Physics Building
University of Malta, Msida MSD2080, MALTA
Edited 8 years ago
 
Register or login to create to post a reply.