Why does my callback funtion collapse?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Apr 5 03:14:02 EDT 2007
En Thu, 05 Apr 2007 03:35:34 -0300, lialie <lialie at gmail.com> escribió:
> I try to callback from a thread in C. But it collapsed. I can't figure
> it out.
- If you are using threads, you must handle the Global Interpreter Lock
(GIL), see http://docs.python.org/api/threads.html
- You don't handle refcounts well:
my_callback = temp;
Py_XINCREF(temp);
Py_XDECREF(my_callback);
The code above does nothing. You must decrement my_callback *before* the
assignment (because you are about to lose a reference to the previous
value) and increment it after (because you keep a reference to the new
value).
--
Gabriel Genellina
More information about the Python-list
mailing list