aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/source/main.h')
-rw-r--r--externals/grill/py/source/main.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h
index b7000bae..e1ae64a4 100644
--- a/externals/grill/py/source/main.h
+++ b/externals/grill/py/source/main.h
@@ -159,16 +159,20 @@ public:
inline void Lock() { mutex.Unlock(); }
inline void Unlock() { mutex.Unlock(); }
+ // this is respecially needed when one py/pyext object calls another one
+ // we don't want the message to be queued, but otoh we have to avoid deadlock
+ static int lockcount;
+
inline PyThreadState *PyLock()
{
- PyEval_AcquireLock();
+ if(!lockcount++) PyEval_AcquireLock();
return PyThreadState_Swap(FindThreadState());
}
inline void PyUnlock(PyThreadState *st)
{
PyThreadState_Swap(st);
- PyEval_ReleaseLock();
+ if(!--lockcount) PyEval_ReleaseLock();
}
#else
inline void Lock() {}