Title: When the SystemRestart exception is thrown, atexit callbacks aren't invoked
Type: behaviour Severity: normal
Components: Core Versions: 2.5.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: colinhevans, pjenvey
Priority: Keywords:

Created on 2009-09-22.01:13:24 by colinhevans, last changed 2009-10-10.05:47:16 by pjenvey.

msg5188 (view) Author: Colin Evans (colinhevans) Date: 2009-09-22.01:13:24
When the SystemRestart exception is thrown, the current interpreter is
restarted, but no atexit callbacks are called, which means that any
threads running in the interpreter can't get shut down cleanly.  The
solution is probably to call PythonInterpreter.cleanup() after the
exception is caught in
msg5210 (view) Author: Philip Jenvey (pjenvey) Date: 2009-10-01.01:25:57
AFAICT cleanup is already called at the end of run()
msg5213 (view) Author: Colin Evans (colinhevans) Date: 2009-10-01.02:03:07
Checking the code, interp.cleanup() is called after 
Py.setSystemState(new PySystemState()); which means that any atexit
handlers got cleared out before cleanup() is called.
msg5214 (view) Author: Philip Jenvey (pjenvey) Date: 2009-10-01.02:57:32
That shouldn't matter as cleanup() is called on the original interpreter 
who'll call its associated PySystemState's exitfunc
msg5228 (view) Author: Philip Jenvey (pjenvey) Date: 2009-10-10.05:47:15
I've confirmed that the exitfuncs are called but I've found that some 
unusual errors can occur during their call. This was due to the sys 
module being cleared via Py.setSystemState beforehand. For example I was 
able to print and call builtin functions in an atexit function, but 
import statements would mysteriously fail. This was all on trunk

I've solved that problem in r6851 -- I'm going to assume that was the 
issue you're hitting and close this out. Reopen if the problem persists
Date User Action Args
2009-10-10 05:47:16pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5228
2009-10-01 02:57:32pjenveysetmessages: + msg5214
2009-10-01 02:03:07colinhevanssetmessages: + msg5213
2009-10-01 01:25:57pjenveysetnosy: + pjenvey
messages: + msg5210
2009-09-22 01:13:24colinhevanscreate