mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
pipeline: Don't exit process when SystemExit happens on external thread
PyErr_Print() causes the process to be forcibly exited when a SystemExit exception occurred, this is a big issue on Android.
This commit is contained in:
parent
25d57e0eef
commit
cc865e6d21
@ -245,16 +245,22 @@ call_python_func(PyObject *function, PyObject *args) {
|
||||
PyObject *exc, *val, *tb;
|
||||
PyErr_Fetch(&exc, &val, &tb);
|
||||
|
||||
thread_cat.error()
|
||||
<< "Exception occurred within " << *current_thread << "\n";
|
||||
|
||||
// Temporarily restore the exception state so we can print a callback
|
||||
// on-the-spot.
|
||||
Py_XINCREF(exc);
|
||||
Py_XINCREF(val);
|
||||
Py_XINCREF(tb);
|
||||
PyErr_Restore(exc, val, tb);
|
||||
PyErr_Print();
|
||||
// on-the-spot, except if it's a SystemExit, which would cause PyErr_Print
|
||||
// to exit the process immediately.
|
||||
if (exc != PyExc_SystemExit) {
|
||||
thread_cat.error()
|
||||
<< "Exception occurred within " << *current_thread << "\n";
|
||||
|
||||
Py_XINCREF(exc);
|
||||
Py_XINCREF(val);
|
||||
Py_XINCREF(tb);
|
||||
PyErr_Restore(exc, val, tb);
|
||||
PyErr_Print();
|
||||
} else {
|
||||
thread_cat.info()
|
||||
<< "SystemExit occurred within " << *current_thread << "\n";
|
||||
}
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user