From e2ca483507b5374bccdd88879f1fbfc52f3dd957 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 5 Jun 2019 12:04:00 +0200 Subject: [PATCH] avoid deadlock between GIL and scan locks --- devsupApp/src/dbrec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/devsupApp/src/dbrec.c b/devsupApp/src/dbrec.c index e85b5e4..7802fe5 100644 --- a/devsupApp/src/dbrec.c +++ b/devsupApp/src/dbrec.c @@ -272,7 +272,9 @@ static PyObject *pyRecord_asyncFinish(pyRecord *self, PyObject *args, PyObject * static PyObject *pyRecord_enter(pyRecord *self) { - dbScanLock(self->entry.precnode->precord); + Py_BEGIN_ALLOW_THREADS { + dbScanLock(self->entry.precnode->precord); + } Py_END_ALLOW_THREADS Py_INCREF(self); return (PyObject*)self; @@ -282,8 +284,10 @@ static PyObject *pyRecord_exit(pyRecord *self, PyObject *args) { PyObject *t, *v, *tb; - /* always unlock, regardless of arguments */ - dbScanUnlock(self->entry.precnode->precord); + Py_BEGIN_ALLOW_THREADS { + /* always unlock, regardless of arguments */ + dbScanUnlock(self->entry.precnode->precord); + } Py_END_ALLOW_THREADS if(!PyArg_ParseTuple(args, "OOO", &t, &v, &tb)) return NULL;