events errors with tangotest or any device server

Hello,

I have a problem with a device server that I developed in c ++ and is using events.
I am using the push_event () method with a callback activated for each new value of a scalar attribute.

I actually have two problems:
1) the callback is unnecessarily activated by an erroneous event.
2) the callback is activated with an identical event value
These two problems occures more often than the polling is fast on the subscribed attribute …

To try to understand how events work, I reproduce the same problems with a python client which subscribes an event on the 'short_scalar' attribute of tangotest.
The 'short_scalar' attribute is configured as follows:
polling: below 50ms
event: absolute and relative 0.1

The client:


import PyTango,time
import sys
import tango

mybool=1

dev='sys/tg_test/1'
dp=PyTango.DeviceProxy(dev)

attrlist=['short_scalar_w','short_scalar']
attr='short_scalar'

class CBTANGOTEST():
def push_event(self,event):
if event.err:
print("error event ",event)
print
return
tce=event.attr_value.value
print ("tangotest event: ",tce)

tcr=dp.read_attributes(attrlist)
print tcr[0].value,tcr[1].value

cb=CBTANGOTEST()
evt=dp.subscribe_event(attr,PyTango.EventType.CHANGE_EVENT,cb)

while mybool==1:
time.sleep(0.1)


The output:


('tangotest event: ', 134)
0 134
('tangotest event: ', 173)
0 173
('tangotest event: ', 89)
0 89
('error event ', EventData(attr_name = 'tango://srv-2.thomx.fr:20000/sys/tg_test/1/short_scalar', attr_value = None, device = TangoTest(sys/tg_test/1), err = True, errors = (DevError(desc = 'The polling thread is late and discard this object polling.\nAdvice: Tune device server polling', origin = 'PollThread::err_out_of_sync', reason = 'API_PollThreadOutOfSync', severity = tango._tango.ErrSeverity.ERR),), event = 'change', reception_date = TimeVal(tv_nsec = 0, tv_sec = 1624538377, tv_usec = 497499)))

('tangotest event: ', 89)
0 89
('error event ', EventData(attr_name = 'tango://srv-2.thomx.fr:20000/sys/tg_test/1/short_scalar', attr_value = None, device = TangoTest(sys/tg_test/1), err = True, errors = (DevError(desc = 'The polling thread is late and discard this object polling.\nAdvice: Tune device server polling', origin = 'PollThread::err_out_of_sync', reason = 'API_PollThreadOutOfSync', severity = tango._tango.ErrSeverity.ERR),), event = 'change', reception_date = TimeVal(tv_nsec = 0, tv_sec = 1624538377, tv_usec = 700628)))

('tangotest event: ', 89)
0 89
('error event ', EventData(attr_name = 'tango://srv-2.thomx.fr:20000/sys/tg_test/1/short_scalar', attr_value = None, device = TangoTest(sys/tg_test/1), err = True, errors = (DevError(desc = 'The polling thread is late and discard this object polling.\nAdvice: Tune device server polling', origin = 'PollThread::err_out_of_sync', reason = 'API_PollThreadOutOfSync', severity = tango._tango.ErrSeverity.ERR),), event = 'change', reception_date = TimeVal(tv_nsec = 0, tv_sec = 1624538377, tv_usec = 898083)))

('tangotest event: ', 89)
0 89
('error event ', EventData(attr_name = 'tango://srv-2.thomx.fr:20000/sys/tg_test/1/short_scalar', attr_value = None, device = TangoTest(sys/tg_test/1), err = True, errors = (DevError(desc = 'The polling thread is late and discard this object polling.\nAdvice: Tune device server polling', origin = 'PollThread::err_out_of_sync', reason = 'API_PollThreadOutOfSync', severity = tango._tango.ErrSeverity.ERR),), event = 'change', reception_date = TimeVal(tv_nsec = 0, tv_sec = 1624538378, tv_usec = 100202)))

('tangotest event: ', 89)
0 89



Can someone tell me if this is normal?
Thanks a lot for your help.
Hi,
I add that, the faster the value of the polling on the attribute, the more the callback is activated.
And, about my environment:

Debian: 9

Tango:

>dpkg -l | grep tango

ii liblog4tango-dev:amd64 9.2.5a+dfsg1-2 amd64 logging for TANGO - development library
ii liblog4tango5v5:amd64 9.2.5a+dfsg1-2 amd64 logging for TANGO - shared library
ii libreoffice-style-tango 1:5.2.7-1+deb9u11 all office productivity suite – Tango symbol style
ii libtango-dev:amd64 9.2.5a+dfsg1-2 amd64 TANGO distributed control system - development library
ii libtango-doc 9.2.5a+dfsg1-2 all TANGO distributed control system - documentation
ii libtango-java 9.2.5a-1 all TANGO java part - shared library
ii libtango-tools 9.2.5a+dfsg1-2 amd64 TANGO distributed control system - common executable files
ii libtango9:amd64 9.2.5a+dfsg1-2 amd64 TANGO distributed control system - shared library
ii python-pytango 9.2.0-2 amd64 transitional dummy package for python-tango
ii python-tango 9.2.0-2 amd64 API for the TANGO control system (Python 2)
ii tango-common 9.2.5a+dfsg1-2 all TANGO distributed control system - common files
ii tango-icon-theme 0.8.90-6 all Tango icon theme
ii tango-starter 9.2.5a+dfsg1-2 amd64 TANGO distributed control system - starter server
ii tango-test 9.2.5a+dfsg1-2 amd64 TANGO distributed control system - test device



libzmq:

dpkg -l |grep libzmq

ii libzmq3-dev:amd64 4.2.1-4+deb9u2 amd64 lightweight messaging kernel (development files)
ii libzmq5:amd64 4.2.1-4+deb9u2 amd64 lightweight messaging kernel (shared library)

Thank you.
Hi,

You're facing the well known "Polling thread is late" problem.
You should follow the advice in the error description : Advice: Tune device server polling

This is expected behaviour if your polling thread cannot do the job as expected.
If your attribute polling period is set to a too small value, the polling thread which is in charge of reading the polled attribute will sometimes not be able to keep up and to respect the configured polling period.
When this happens, the Tango polling thread is not able to read the attribute in the expected configured period and might skip reading some attributes sometimes.
When this happens, Tango informs the clients who subscribed to events on the concerned attributes with the error you're seeing:

The polling thread is late and discard this object polling.
Advice: Tune device server polling


This is expected behaviour.
Then the next time the polling manages to read the attribute again, it sends a new event with the read value.
Since the previous event sent was an error event, Tango considers that the situation changed for this attribute and that it should send an event.

The callback is not activated with an identical value as your were writing.
Tango considers that the value changed because there was an error event, followed by a correct event. The content of the events data is different (once there was an error and then there was a correct value. So there is a change to be notified to the client).
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
 
Register or login to create to post a reply.