(Win32 API) callback to Python, threading hiccups
Gregory Bond
gnb at itga.com.au
Fri Jul 8 03:05:18 EDT 2005
Tim Roberts wrote:
>>> PyGILState_STATE gil = PyGILState_Ensure();
>>> result = PyEval_CallObject(my_callback, arglist);
>>> PyGILState_Release(gil);
>>> Py_DECREF(arglist);
>>> Py_DECREF(result);
> If someone else holds a reference to "arglist", then the
> DECREF is just a nice, atomic decrement. If no one else holds a reference
> to "arglist", then it's quite safe to delete it.
What if anothere thread takes the GIL as soon as you release it, and is
attempting to allcate a new opbject, and (at the same time - you might
be on a multiprocessor!) your PyDECREF removes the last reference and
starts freeing objects?
More information about the Python-list
mailing list