> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > g] On Behalf Of pydev > Sent: Tuesday, April 11, 2006 9:23 PM > Subject: multi-threaded c++ callback problem > > void pyCallEventCallback( CALL hCall, > LINE hLine, > CALLSTATE_MAJOR eMajor, > CALLSTATE_MINOR eMinor, > PyObject* def ) > { > if( !PyCallable_Check( def ) ) > { > PyErr_SetString( PyExc_TypeError, "Need a callable object!" ); > return; > } > printf( "EventCallback hCall: %i, hLine: %i, eMajor: %i, > eMinor: %i\n", hCall, hLine, eMajor, eMinor); > PyObject* arglist = Py_BuildValue("(iiii)", hCall, hLine, > eMajor, eMinor); > > // if i comment out next line it works! > PyEval_CallObject( def, arglist ); > > Py_XDECREF(arglist); > } > //-----------------------------------------------------------//
Wild guess because of lack of context: It's a race condition because you haven't acquired the GIL before calling pyCallEventCallback. You can do so by using PyEval_SaveThread and friends. You have to make sure to call PyEval_InitThreads somewhere, e.g. when embedding from within the interpreter initialisation boilerplate, when extending for instance from within the extension module initialisation. cheers, aa -- Andreas Ames | Programmer | Comergo GmbH | Voice: +49 69 7505 3213 | ames AT avaya . com -- http://mail.python.org/mailman/listinfo/python-list