Re: help with callback from C dll

Mads Kiilerich <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
On 06/11/2010 12:06 PM, Adam Morris wrote:
> Thanks for your help,
>
> I have a dynamic library from a commercial company and I'm porting it to
> Python to be used from within my own scripts. I'm using ctypes to do so.
>
> The library requires me to send it a function to be used as a callback.
> Everything else works fine, except when this callback gets called: I'm
> consistently getting bus errors.
>
> I'm guessing that it's because their C code is initiating threads, and
> the normal procedure is to reinstate the GIL and then call the callback?
> And to do that, you need to do so in C.
>
> Does this mean that I have to write a wrapper over top of the dynamic
> library in order to get this working in Python?

AFAIK ctypes should handle GIL correctly automatically, also when used 
from threads.

To me it sounds more like a problem with bad alignment or bad parameter 
profile of the callback function.

/Mads

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.