<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV>hi all,</DIV>
<DIV> </DIV>
<DIV>i'm building a wrapper for a multi-threaded c++ library to use it
in python. </DIV>
<DIV>everything works fine except the callback.</DIV>
<DIV> </DIV>
<DIV>the c++ code to call the python function:</DIV>
<DIV>//-----------------------------------------------------------//</DIV>
<DIV>void pyCallEventCallback( CALL hCall,
<BR>
LINE
hLine,
<BR>
CALLSTATE_MAJOR
eMajor,<BR>
CALLSTATE_MINOR
eMinor, <BR>
PyObject* def )<BR>{<BR> if( !PyCallable_Check( def ) )
<BR> {<BR>
PyErr_SetString( PyExc_TypeError, "Need a callable object!"
);<BR> return;<BR>
}<BR> printf( "EventCallback hCall: %i, hLine: %i, eMajor: %i,
eMinor: %i\n", hCall, hLine, eMajor, eMinor);<BR> PyObject*
arglist = Py_BuildValue("(iiii)", hCall, hLine, eMajor, eMinor);</DIV>
<DIV> </DIV>
<DIV> // if i comment out next line it
works!<BR> PyEval_CallObject( def, arglist ); </DIV>
<DIV> </DIV>
<DIV> Py_XDECREF(arglist); <BR>}</DIV>
<DIV>//-----------------------------------------------------------//</DIV>
<DIV> </DIV>
<DIV>the python callback function looks like this:</DIV>
<DIV>//-----------------------------------------------------------//</DIV>
<DIV>def callback( *args ):</DIV>
<DIV> print "callback:", args</DIV>
<DIV>//-----------------------------------------------------------//</DIV>
<DIV> </DIV>
<DIV>the soutput i get looks like this:</DIV>
<DIV> </DIV>
<DIV>EventCallback hCall: 1, hLine: 1, eMajor: 2000, eMinor: 2001</DIV>
<DIV>callback: ( 1, 1, 2000, 2001 )</DIV>
<DIV>EventCallback hCall: 1, hLine: 1, eMajor: 2500, eMinor: 2501</DIV>
<DIV>callback: ( 1, 1, 2500, 2501 )</DIV>
<DIV>EventCallback hCall: 1, hLine: 1, eMajor: 8000, eMinor: 8001</DIV>
<DIV>an then instead of: callback: ( 1, 1, 8000, 8001)</DIV>
<DIV>it crashes</DIV>
<DIV> </DIV>
<DIV>there are no other python interactions between the callback
calls.</DIV></BODY></HTML>