win32ui crashes on exit with large wx Application
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
Under Windows 8.1 / Python27 64Bit / pywin32 build 219 there seems to be a race condition during the shutdown of the application.
Debugging showed, that some Windows messages are sent AFTER the Python interpreter has already shut down (Py_Finalize already called).
The call to
//win32win.cpp:77 (inside Python_check_message) CEnterLeavePython _celp;
is therefore working with a dead python instance and crashes.
Suggested fix:
The error can be prevented, if the following code is added to the win32uimodule.cpp file:
static void UnhookWindowsMessages() { if (hhook) UnhookWindowsHookEx(hhook); hhook = 0; } static void win32ui_finalize (void) { UnhookWindowsMessages(); } // At the end of PYWIN_MODULE_INIT_FUNC(win32ui): Py_AtExit(win32ui_finalize);
Working with Py_AtExit is not always the best choice, but in this case it seems legit.