I agree. Then we could call sys.exit() as the standard call to end,
rather than core.quit(). And this could force shutdown of several
objects to run their __del__() method avoiding some of the issues we
currently have.
For instance, if an ExperimentHandler ends up with a circular reference
with something then its __del__ method doesn't get called because
garbage collection fails to pick it up. When that happens
del myExp #fails
myExp.__del__() #succeeds and will force the data save to occur
So we could register really important things like ExperimentHandlers (as
a list of weak references) in psychopy.core and then force a call to
their __del__ methods during sys.exit. Alternatively, yes, registering
the shutdown methods for each object with atexit would be another way to
go. What happens then if the object has been deleted before the sys.exit
is called? Do we have to remember to de-register?
2 questions - minor issues that we should just check:
- if we have sys.exit() in core.quit and core.quit is handled by
atexit, does Python detect/avoid the circularity?
- does this play nicely with the calls to __del__ for our existing
objects? (I imagine it does and possibly works better)
cheers
Jon
--
Jonathan Peirce
University of Nottingham
http://www.peirce.org.uk
This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it.
Please do not use, copy or disclose the information contained in this
message or in any attachment. Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.
This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.