Skip to content

Instantly share code, notes, and snippets.

@projectgus
Created November 8, 2012 22:13
Show Gist options
  • Save projectgus/4042083 to your computer and use it in GitHub Desktop.
Save projectgus/4042083 to your computer and use it in GitHub Desktop.
Demonstration of callbacks coming from otherwise stale PV object
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)
@projectgus
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment