Avoid function-local statics that call Python code to avoid deadlocks with GIL

This commit is contained in:
Petr Mitrichev 2018-06-28 14:27:52 +02:00
commit d956081fd3
2 changed files with 49 additions and 9 deletions

View file

@ -431,6 +431,11 @@ SWIG_init(void) {
SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
#endif #endif
SWIG_Py_None_global_Init();
SwigPyObject_type_global_Init();
SwigPyPacked_type_global_Init();
SWIG_Python_TypeCache_global_Init();
SWIG_InstallConstants(d,swig_const_table); SWIG_InstallConstants(d,swig_const_table);
%} %}

View file

@ -258,11 +258,24 @@ _SWIG_Py_None(void)
Py_DECREF(none); Py_DECREF(none);
return none; return none;
} }
static PyObject *SWIG_Py_None_global = 0;
SWIGRUNTIME void SWIG_Py_None_global_Init(void) {
SWIG_Py_None_global = _SWIG_Py_None();
}
SWIGRUNTIME PyObject * SWIGRUNTIME PyObject *
SWIG_Py_None(void) SWIG_Py_None(void)
{ {
static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); assert(SWIG_Py_None_global);
return none; return SWIG_Py_None_global;
}
#else
SWIGRUNTIME void SWIG_Py_None_global_Init(void)
{
// Do nothing
} }
#endif #endif
@ -488,11 +501,21 @@ SwigPyObject_type(void) {
assert(cd->pytype); assert(cd->pytype);
return cd->pytype; return cd->pytype;
} }
SWIGRUNTIME void SwigPyObject_type_global_Init(void) {
// Do nothing
}
#else #else
static PyTypeObject *SwigPyObject_type_global = 0;
SWIGRUNTIME void SwigPyObject_type_global_Init(void) {
SwigPyObject_type_global = SwigPyObject_TypeOnce();
}
SWIGRUNTIME PyTypeObject* SWIGRUNTIME PyTypeObject*
SwigPyObject_type(void) { SwigPyObject_type(void) {
static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); assert(SwigPyObject_type_global);
return type; return SwigPyObject_type_global;
} }
#endif #endif
@ -836,10 +859,16 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
static PyTypeObject* SwigPyPacked_type_global = 0;
SWIGRUNTIME void SwigPyPacked_type_global_Init(void) {
SwigPyPacked_type_global = SwigPyPacked_TypeOnce();
}
SWIGRUNTIME PyTypeObject* SWIGRUNTIME PyTypeObject*
SwigPyPacked_type(void) { SwigPyPacked_type(void) {
static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); assert(SwigPyPacked_type_global);
return type; return SwigPyPacked_type_global;
} }
SWIGRUNTIMEINLINE int SWIGRUNTIMEINLINE int
@ -1438,11 +1467,17 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
} }
} }
static PyObject *SWIG_Python_TypeCache_global = 0;
SWIGRUNTIME void SWIG_Python_TypeCache_global_Init(void) {
SWIG_Python_TypeCache_global = PyDict_New();
}
/* The python cached type query */ /* The python cached type query */
SWIGRUNTIME PyObject * SWIGRUNTIME PyObject *
SWIG_Python_TypeCache(void) { SWIG_Python_TypeCache(void) {
static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); assert(SWIG_Python_TypeCache_global);
return cache; return SWIG_Python_TypeCache_global;
} }
SWIGRUNTIME swig_type_info * SWIGRUNTIME swig_type_info *