Stefan Behnel schrieb:
> Martin Gysel wrote:
>   
>> Stefan Behnel wrote:
>>     
>> I register it and it gets called at some time. As
>> already said, the library starts a new thread... at the time the
>> callback gets called no cython code is supposed to run except the
>> callback itself of course.
>>
>> 1. register callback
>> 2. start library thread
>> 3. ... (at the moment I just do nothing apart of waiting)
>>     
>
> How do you wait? using time.wait()?
>   
no, for now I just use the console and wait for some printouts...
>   
>> 4. callback gets called (here I want to deal with either the library or
>> my cython object)
>> 5. segfault :-(
>>
>> really strange for me is it segfaults immediately if I use with gil. is
>> it possible the gil is held by another function?
>>     
>
> No. The GIL is an exclusive lock. When you get hold of it, you are the
> only one who has it. Declaring your callback function "with gil" is
> exactly the right thing to do here.
>
> BTW, are you sure that threading support has been initialised in your
> program? Just a wild guess, but maybe "import threading" at module level
> helps? If so, we may be able to fix that.
>
> It would be good if you could come up with a small test program that shows
> exactly the code you use. Also, so far, we do not know which library you
> are interfacing with. Is the library thread based on pthreads (which
> Python uses)?
>   
my cython code is available  here [1]. It interfaces with PulseAudio
[2]. I don't know which library pulseaudio uses...
I tried different combinations, with and without gil on the functions
named *_cb(...) ....
to compile it simply type:
gcc -g -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing
-I/usr/include/python2.5 -lpulse -o pulse.so pulse.c
(you need pulseaudio to be installed)

/martin


[1] https://bitbucket.org/bearsh/alpaka/raw/tip/contents/code/pulse.pyx
[2] http://www.pulseaudio.org

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

Reply via email to