-
Notifications
You must be signed in to change notification settings - Fork 44
Keeping references to event callbacks after unsubscribe_event #185
Comments
Hi @reszelaz and thanks for the report! After some investigation it turns out the device proxy keeps the callback in memory for at least a minute after the call to import gc
import sys
import time
import tango
def callback(*args):
print(args)
# Run
dp = tango.DeviceProxy("sys/tg_test/1")
eid = dp.subscribe_event('time', tango.EventType.CHANGE_EVENT, callback)
dp.unsubscribe_event(eid)
# Cleanup
time.sleep(61)
try:
dp.unsubscribe_event(eid)
except KeyError:
sys.exc_clear()
# Check
assert gc.get_referrers(callback) == [globals()] |
Thanks for the investigation! The current behavior seems to be a little "fragile". Do you plan to change it? Actually we found this when working on two issues in Taurus: taurus-org/taurus#511 and taurus-org/taurus#512. @cmft and @cpascual figured out a workaround that is already integrated in Taurus so there is no big rush with this discussion. When we will get a breath after the Taurus and Sardana releases we will get back to you. |
It definitely is. There are several ways to tackle this issue:
|
Great! If you need any help in testing any of this solutions we are willing to help! |
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:
we can see the following output:
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!
The text was updated successfully, but these errors were encountered: