Robert Bradshaw schrieb:
> On Mar 18, 2009, at 2:17 PM, Martin Gysel wrote:
>
>   
>> Hi
>>
>> I have a 'cython' class which interfaces c code. therefor I need some
>> callback functions which I declared outside of the class. Over a
>> userdata argument pointer this function gets the reference of my  
>> class.
>> Callback registration and also the callback itself work. The  
>> problem is,
>> as soon as the callback starts to execute, I'll get a segfault (from
>> time to time it also works...). So I debugged the c code, the segfault
>> occurs while getting the sdtout for the print statement. So I removed
>> all print statements but from my callback I want to call either a
>> function of my class or some python callback (which needs to be
>> registered first). For me it seems the segfault occurs when accessing
>> some python objects. I also tried to play around with 'which gil' and
>> 'nogil' but no luck. When using 'which gil' it segfaults  
>> immediately the
>> callback gets called.
>> What do I wrong? I assume it should be possible to have print in
>> callback functions and also to have access to python objects.
>>     
>
> Yes, that should be possible. It does sound like you're having  
> threading/gil issues. What is your callback function signature? When  
> you say you've tried "with gil" are you doing
>
> cdef void my_callback(void *data) with gil:
>      ...
>   
yes exactly (well some more arguments...). I forgot to mention that the
callback gets called from another thread as the library which I want to
interface starts such a thread. Probably thats the point. But how can I
assure that another thread can safely call my code?

/martin

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to