BUG: duplicated events if server had in his history clients with IDL5 and IDL6

@jkotan found an issue with evenst for tango 10.0.2 and I can reproduce it with current dev:

First we start server, which emits events:

from tango.server import Device, attribute, command

class TestDevice(Device):

    def init_device(self):
        super().init_device()
        self.set_change_event("attr", True, False)

    @attribute
    def attr(self):
        return 1

    @command
    def send_event(self):
        self.push_change_event("attr", 2)


if __name__ == "__main__":
    TestDevice.run_server()

Then we subscribe from tango10 client (IDL6), send event ones leave DeviceProxy running:

import time
from tango import DeviceProxy, EventType, DevFailed


def cb(event):
    try:
        dp = DeviceProxy("dserver/testdevice/test")
        print(f"Got event : {dp.command_inout('QueryEventSystem')}")
    except:
        print("Got event")


if __name__ == "__main__":
    dp = DeviceProxy("device/test/1")
    dp.subscribe_event("attr", EventType.CHANGE_EVENT, cb)
    dp.send_event()

    while True:
        time.sleep(1)

As expected we get two events:

(tangodev_13) matveyev@haso102ym:~/pytango_duplicate/sandbox$ python server_for_tests.py
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":1},"perf":null},"client":null}
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":2},"perf":null},"client":null}

And now (while first one running) we do the same from tango9 (IDL5) and both clients get event twice:

IDL6 client:

(tangodev_13) matveyev@haso102ym:~/pytango_duplicate/sandbox$ python server_for_tests.py
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":1},"perf":null},"client":null}
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":2},"perf":null},"client":null}
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":3},"perf":null},"client":null}
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":3},"perf":null},"client":null}

IDL5 client:

(tango93_9) matveyev@haso102ym:~/pytango_duplicate/sandbox$ python server_for_tests.py 
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":2},"perf":null},"client":null}
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":3},"perf":null},"client":null}
Got event : {"version":1,"server":{"event_counters":{"tango://haso102ym.desy.de:10000/device/test/1/attr.change":3},"perf":null},"client":null}
Edited by Yury Matveev