Keeping references to event callbacks after unsubscribe_event

Hi PyTango experts!

We have observed that the reference to the callback (either method or function) is being maintained after unsubscribing from the event. We have checked it for configuration and change event.

After executing this code:

import gc
import tango

def fcb(*args, **kwargs):
    pass

dp = tango.DeviceProxy("sys/tg_test/1")
print "Before sub:", len(gc.get_referrers(fcb))
_id = dp.subscribe_event("double_scalar", tango.EventType.CHANGE_EVENT, fcb)
print "After sub: ", len(gc.get_referrers(fcb))
dp.unsubscribe_event(_id)
gc.collect()
print "After unsub:", len(gc.get_referrers(fcb))

we can see the following output:

Before sub: 1
After sub:  2
After unsub: 2

Note that this does not happen with PyTango 7.2.6 but with PyTango 8.1.2 and PyTango 9.2.2.

Could you confirm that this is a bug?

Thanks!

Edited Mar 03, 2023 by Ghost User
Assignee Loading
Time tracking Loading