From 9eebe8b7ff2a6a003e771c5312a43c26469e2b9c Mon Sep 17 00:00:00 2001 From: Alex Gorrod Date: Wed, 15 Jan 2014 22:18:30 +1100 Subject: 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 --- lang/python/wiredtiger.i | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lang/python/wiredtiger.i') 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); } -- cgit v1.2.1