Hello guys, Im still implementing my callback to python from my dll and the python interpreter crashes
I have no idea atm why
I use the calldll module for calling my c++-dll from my module calldllsound.py:
import calldll
import struct
class CallSoundDLL:
def __init__(self, library):
self.library = library
def myGetResults(a):
print a #just for debugging
calldll.call_foreign_function (self.addrGet,'llllll','i',(self.ulHz.address(), self.dNoise.address(), self.bAudio.address(),self.bCrackFlag.address(), self.dSNR.address(), self.bBeep.address()))
def mySetCallback(self):
calldll.call_foreign_function (self.addrCall,'O','',(self.myGetResults,))
def start(self):
# ---------------------------------------------------------------------------------------------
# Get the handle of the dll and the address of the function
# ---------------------------------------------------------------------------------------------
#Get the handle of the Dll
handle = calldll.load_library (self.library)
#Get the address of the functions
self.addrStart = calldll.get_proc_address (handle, 'StartProcessing')
self.addrEnd = calldll.get_proc_address (handle, 'EndProcessing')
self.addrGet = calldll.get_proc_address (handle, 'GetResults')
self.addrCall = calldll.get_proc_address (handle, 'my_set_callback')
# ---------------------------------------------------------------------------------------------
# Initialization
# ---------------------------------------------------------------------------------------------
self.ulHz = calldll.membuf(4) #unsigned long*
self.dNoise = calldll.membuf(8) #double*
self.bAudio = calldll.membuf(4) #int*
self.bCrackFlag = calldll.membuf(4) #int*
self.dSNR = calldll.membuf(8) #double*
self.bBeep = calldll.membuf(4) #int*
# ---------------------------------------------------------------------------------------------
# Function calling
# ---------------------------------------------------------------------------------------------
args = (1,1,1,1,1,1000)
calldll.call_foreign_function (self.addrStart,'iiiiik','i',args)
So Im starting my dll on such a way:
>>> import calldllsound
>>> obj = calldllsound.CallSoundDLL("soundproclib.dll")
>>> obj.start()
It works without any problems.
But after the following command crashes the python interpreter...:
>>> obj.mySetCallback()
Here is my_set_callback function from my dll, which have to be called in the python function mySetCallback:
static PyObject *my_callback = NULL;
PyMODINIT_FUNC my_set_callback(PyObject *args)
{
PyObject *temp = args;
Py_XINCREF(temp); /* Add a reference to new callback */
Py_XDECREF(my_callback); /* Dispose of previous callback */
my_callback = temp; /* Remember new callback */
Py_INCREF(Py_None);
bPyCallBackFlag = true;
};
and here is the part of my code from the same c++-file where Im trying to call my python-function myGetResults:
if (bPyCallBackFlag)
{
/* Time to call the callback */
ppyobjArgList = Py_BuildValue("(i)",123); //just for debugging
// Here crashes the python interpreter, I found it out with
// error logging:
ppyobjResult = PyObject_CallObject(my_callback, ppyobjArgList);
Py_DECREF(ppyobjResult);
}
Have anybody any idea why it doesnt work?
Thank you very much
Gesendet von Yahoo! Mail - Jetzt mit 1GB kostenlosem Speicher
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32