psychopy.org | Reference | Downloads | Github

Exiting with core.quit() or sys.exit()


#1

Can I safely close the application with sys.exit(‘msg’) or is it necessary to call core.quit()?
I am asking because I have seen a few examles where is sys.exit(‘msg’) used and I do not understand the difference.


#2

The code for core.quit() is here:

As you can see, .core.quit() calls sys.exit() itself, but before that, it does some PsychoPy-specific tidying. So you should use it. In effect core.quit() means “quit PsychoPy and then exit Python”.

Maybe in the examples you found, people used sys.exit() because they are experienced Python programmers but perhaps not so used to the PsychoPy API.