summaryrefslogtreecommitdiff
path: root/lang/python/wiredtiger.i
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-01-15 22:18:30 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2014-01-15 22:18:30 +1100
commit9eebe8b7ff2a6a003e771c5312a43c26469e2b9c (patch)
tree74536e3df7361673bed2f8e7d84d2f55529d3668 /lang/python/wiredtiger.i
parent329d6b6b6bbc75fb384b22908f7d8924398dbfd1 (diff)
downloadmongo-9eebe8b7ff2a6a003e771c5312a43c26469e2b9c.tar.gz
Fix bug in Python SWIG layer.
The Python interpreter can shut down threading before we are finished with it unless an explicit lock is taken. See: http://stackoverflow.com/questions/12178897/swig-crashes-python
Diffstat (limited to 'lang/python/wiredtiger.i')
-rw-r--r--lang/python/wiredtiger.i9
1 files changed, 9 insertions, 0 deletions
diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i
index b2cfa9be7c9..670486a541d 100644
--- a/lang/python/wiredtiger.i
+++ b/lang/python/wiredtiger.i
@@ -656,12 +656,21 @@ pythonClose(PY_CALLBACK *pcb)
{
int ret;
+ /*
+ * Ensure the global interpreter lock is held - so that Python
+ * doesn't shut down threads while we use them.
+ */
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+
ret = 0;
if (PyObject_SetAttrString(pcb->pyobj, "this", Py_None) == -1) {
SWIG_Error(SWIG_RuntimeError, "WT SetAttr failed");
ret = EINVAL; /* any non-zero value will do. */
}
Py_XDECREF(pcb->pyobj);
+
+ SWIG_PYTHON_THREAD_END_BLOCK;
+
return (ret);
}