Created
November 8, 2012 22:13
-
-
Save projectgus/4042083 to your computer and use it in GitHub Desktop.
Demonstration of callbacks coming from otherwise stale PV object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import epics, time | |
pvname = "c1v0:UPTIME" | |
def my_callback(value, **kw): | |
print value | |
def setup_callback(): | |
pv = epics.PV(pvname) | |
pv.add_callback(my_callback) | |
setup_callback() | |
# Do you expect to see any callbacks from the dead PV object, here? | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On master branch - PV not garbage collected, regular callbacks during the sleep() period.
On fix branch - PV garbage collected, no callbacks during the sleep() period.
I think the desirable behaviour is definitely the second one, but I can see how some people might possibly have relied on the existing behaviour. I do think it's bad coding practice to expect an object to hang around after you've stopped referencing it, though.