aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pyext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/source/pyext.cpp')
-rw-r--r--externals/grill/py/source/pyext.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp
index 31945277..2eabf12e 100644
--- a/externals/grill/py/source/pyext.cpp
+++ b/externals/grill/py/source/pyext.cpp
@@ -219,6 +219,34 @@ bool pyext::Init()
return pyobj && flext_dsp::Init();
}
+bool pyext::Finalize()
+{
+ bool ok = true;
+ ThrState state = PyLockSys();
+
+ PyObject *init = PyObject_GetAttrString(pyobj,"_init"); // get ref
+ if(init) {
+ if(PyMethod_Check(init)) {
+ PyObject *res = PyObject_CallObject(init,NULL);
+ if(!res) {
+ // exception is set
+ ok = false;
+ // we want to know why __init__ failed...
+ PyErr_Print();
+ }
+ else
+ Py_DECREF(res);
+ }
+ Py_DECREF(init);
+ }
+ else
+ // __init__ has not been found - don't care
+ PyErr_Clear();
+
+ PyUnlock(state);
+ return ok && flext_dsp::Finalize();
+}
+
void pyext::Exit()
{
pybase::Exit(); // exit threads