diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2007-07-06 21:44:56 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2007-07-06 21:44:56 +0000 |
commit | 3922cb5abcd451238047713829456e50f94dade2 (patch) | |
tree | 990cb81fcccfc5bbe3807442401615ec76b66d44 /externals/grill/py/source/pyext.cpp | |
parent | d58dd27f1324e4d33a3f09637b2c06198dd27df4 (diff) |
adapting to new flext lockfree structures
much better detach method handling (one thread for all object instances)
use PyGILState_\*() functionality (enabled with PY_USE_GIL)
ooops, fixing typo
fixing numpy initialization quirks
pyext._init is now called after __init__
enabled use of inofficial PD functionality for search and help path access (#define PY_USE_INOFFICIAL)
added sketch for new pye (Python expression) object
buffer protocol adapted for Python 2.5
svn path=/trunk/; revision=7903
Diffstat (limited to 'externals/grill/py/source/pyext.cpp')
-rw-r--r-- | externals/grill/py/source/pyext.cpp | 28 |
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 |