aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pyext.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-11-10 03:31:34 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-11-10 03:31:34 +0000
commit7ca685c4bc0b2881555f317db6408ae488fe05aa (patch)
treed8b1c4cf5368e40cad34da16c2eef979112994d5 /externals/grill/py/source/pyext.cpp
parent5901f4586235caba9fd264ff1e911708efe6cb17 (diff)
support for Python threads, at last
svn path=/trunk/; revision=2251
Diffstat (limited to 'externals/grill/py/source/pyext.cpp')
-rw-r--r--externals/grill/py/source/pyext.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp
index 27ad942b..9e1ff30b 100644
--- a/externals/grill/py/source/pyext.cpp
+++ b/externals/grill/py/source/pyext.cpp
@@ -2,7 +2,7 @@
py/pyext - python script object for PD and Max/MSP
-Copyright (c)2002-2004 Thomas Grill (xovo@gmx.net)
+Copyright (c)2002-2004 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
@@ -256,10 +256,14 @@ pyext::~pyext()
PY_LOCK
ClearBinding();
- Unregister("_pyext");
- UnimportModule();
+
+ if(pyobj) {
+ if(pyobj->ob_refcnt > 1) post("%s - Python object is still referenced",thisName());
+ Py_DECREF(pyobj); // opposite of SetClssMeth
+ }
- Py_XDECREF(pyobj); // opposite of SetClssMeth
+ Unregister("_pyext");
+ UnimportModule();
PY_UNLOCK
}
@@ -495,13 +499,9 @@ V pyext::work_wrapper(V *data)
// get the global lock
PyEval_AcquireLock();
// create a thread state object for this thread
- PyThreadState *newthr = PyThreadState_New(pystate);
+ PyThreadState *newthr = FindThreadState();
// free the lock
PyEval_ReleaseLock();
- // -----------------------------
-
- // store new thread state
- pythrmap[GetThreadId()] = newthr;
#endif
{
// call worker
@@ -511,18 +511,13 @@ V pyext::work_wrapper(V *data)
}
#ifdef FLEXT_THREADS
- // delete mapped thread state
- pythrmap.erase(GetThreadId());
-
// --- delete Python thread ---
// grab the lock
PyEval_AcquireLock();
// swap my thread state out of the interpreter
PyThreadState_Swap(NULL);
- // clear out any cruft from thread state object
- PyThreadState_Clear(newthr);
- // delete my thread state object
- PyThreadState_Delete(newthr);
+ // delete mapped thread state
+ FreeThreadState();
// release the lock
PyEval_ReleaseLock();
// -----------------------------