Python uses a Global Interpreter Lock (GIL) to ensures that Python code in only executing in a single thread at a time.
When you use the Python C API and/or expose C++ code to Python, you have to re-acquire the GIL each time you call in a C Python API. This is also true when writing Python extensions for Maya or when using the Python C API from a Maya plug-ins.
You will need to add these calls in a few high-level places in your code, like this:
PyGILState_STATE state = PyGILState_Ensure(); // call your python code here: PyGILState_Release(state);
Comments
You can follow this conversation by subscribing to the comment feed for this post.