python, ctypes, callbacks -- access violation when calling callback
lists at cheimes.de
Sun Jul 19 11:09:37 EDT 2009
> Can anybody explain my errors when trying to pass callback to DLL
> Thanks for advices and solutions!
You have to keep a reference to the callback alive yourself. ctypes
doesn't increase the refernece counter of the function when you define a
callback. As soon as the ref counter reaches 0, the function object is
collected and the pointer to the callback is invalid.
You could assign it to a module global or instance variable.
More information about the Python-list