Why device attribute list is different during server initialization and at runtime?

Hello all,

I have a question regarding the device attribute list on the server side.
I use a PyTango DS and only dynamic attributes (created with dyn_attr() of the DeviceClass).
When I get the list of attributes (using <Device_Impl>.get_device_attr()) it is empty during server initialization but when called at runtime it returns attributes added to other devices of this class. Note that during the server initialization we also add attributes to the devices of this class.

You can use this example DS to reproduce this issue by following these steps (do not follow the steps from the repository):

In one console (here the lines starting from “remove device attribute: attr1” appears after executing the code in the second console)


tango_admin --add-server DeviceServer/test PoolDevice test/pooldevice/1                                                                              tango_admin --add-server DeviceServer/test MyDevice test/mydevice/1
tango_admin --add-server DeviceServer/test MyDevice test/mydevice/2

python3 DeviceServer.py test -v4
remove class attr: attr2
Ready to accept request
Ready to accept request
remove device attribute: attr1
remove device attribute: attr2
remove class attr: attr2
remove device attribute: attr3

In another python console (after starting the server:


import tango
pool = tango.DeviceProxy("test/pooldevice/1")
pool.CreateDevice(["MyDevice", "test/mydevice/3"])

You can find me on Slack to clarify any doubt about this question.

Many thanks,
Zibi

Hi Zibi,

I found this in cpptango doxygen documentation for Tango::DeviceImpl::add_attribute method:

If you don’t like this behaviour, you should create only 1 device of your class per device server process.

Hoping this helps a bit.
Reynald

Thanks Reynald for so fast reply! You helped a lot!

The clue is this part of the docs you pointed:

At least in case of PyTango, during the server initialization, first all the devices of a given class are created and then we call add_attribute() in the dyn_attr() method. In this case none of the devices will have attributes cause the device class did not have any attribute when the devices were being created. This changes if we create a device at runtime. Here the device class is already aware of the previously added attrbiutes.