Re: Passing self though to callbacks

eryk sun <[email protected]> Fri, 4 Mar 2016 04:16:57 -0600
Newsgroups gmane.comp.python.ctypes
Message-ID <CACL+1avBb70djz4Ca9J5PZw=4sAssB7A6PDPmzZC-GHXpn4qFA@mail.gmail.com>
On Thu, Mar 3, 2016 at 4:38 AM, Glenn Pierce <[email protected]> wrote:
> I can pass the int now. I was retrieving with.value and not .contents
>
> If anyone has a simpler way though please let me know.

Using id(self) as a void* is wrong in general. It's not incrementing
the reference count. But with ctypes you should almost always ignore
the context parameter of C callbacks. Pass None (i.e. NULL) for the
context. Instead use a bound method as the callable. You'll get the
self reference for free, which gives you all the context that you'll
ever need.

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140