Skip to content Skip to sidebar Skip to footer

Python Ctypes Weird Behavior

I am trying to design a bot for an application called Virtual Paradise and the SDK that is given for building the bot is compiled into a shared library, therefore I have to use cty

Solution 1:

You must maintain a reference to the wrapped function for the lifetime it may be called. See the Important note... at the end of 15.16.1.17. Callback functions in the Python ctypes documentation.

One way is to use self.event_chat_func instead, storing it for the lifetime of the containing object.

Also, creating chat.VPSDK(vp, instance) creates an instance of chat.VPSDK that goes out of scope in the next line. You don't demonstrate how bot is instantiated in the first example, but the VPSDK object doesn't live very long.


Post a Comment for "Python Ctypes Weird Behavior"