Re: (Win32 API) callback to Python, threading hiccups
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: (Win32 API) callback to Python, threading hiccups

From: Scott David Daniels <Scott.Daniels@Acm.Org>
Date: Thu Jul 07 2005 - 17:47:15 CEST

Francois De Serres wrote:
> PyGILState_STATE gil = PyGILState_Ensure();
> result = PyEval_CallObject(my_callback, arglist);
> PyGILState_Release(gil);
> Py_DECREF(arglist);
> Py_DECREF(result);

I think this should be:
          PyGILState_STATE gil = PyGILState_Ensure();
          result = PyEval_CallObject(my_callback, arglist);
          Py_DECREF(arglist);
          Py_DECREF(result);
          PyGILState_Release(gil);

The DECREFs need to be protected, that is where storage is
recycled and such, and you still need Python's data structures
to do that kind of work.

--Scott David Daniels
Received on Thu Sep 29 16:48:58 2005