logo       

too much work in c function: msg#00053

python.pyrex

Subject: too much work in c function

hi all,

i have a problem that someone on this list might be able to help with.  i've stripped down this code sample to hopefully just the part that matters for demonstration purposes.  if it's not enough, i'll be glad to post more.  the problem is that the cfunc_do_work() function calls the _callback_wrapper function 36 times per second.  the _callback_wrapper then calls back into the python code that was passed as the callback parameter of Play.play().  a user of this library in using it in a wxPython gui application.  when Play.play() is called, wxPython is not very responsive even when explicitly calling wxYield to refresh the interface in the python callback function.  my first instinct was that this might be a GIL problem and somehow i must make sure that pyrex doesn't own the GIL while cfunc_do_work() is called.  i looked at the pyrex generated c code and i don't see any GIL functions being called, so i'm not sure if i implicitly have it or not, where and how i'm supposed to release it, or if this is even the real problem.


cdef class Play:              
    def play(self, callback=None):
        cfunc_set_callback(_callback_wrapper, <void*>callback)
        while(cfunc_do_work()): pass           
                                                     
       
cdef int _callback_wrapper(void *callback) except *:     
    return (<object>callback)()       



thanks,


bryan
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise