On 6/8/07, Ka-Hing Cheung <[EMAIL PROTECTED]> wrote:
On Fri, 2007-06-08 at 08:09 +0800, Ludovic Coquelle wrote: > Thank for the reply. > I have no idea about the behaviour regarding the GIL. > > But I found that my problem is due to the python wrapper: this is not > a bug but it cannot allow threading. > What happens is that the python 'dispatch' call the underlying C > 'dispatch' (of course) in one python thread. But doing that, python do > not control any more this thread, and thus the interpreter is blocked > by this call. > If I add a timer event in the loop with a callback doing nothing > (createTimer(lambda fd,evt,obj: sleep(0)).addToLoop(timeout=0)), the C > code call back the python code and the other trheads can be > executed ... but why use event if there is a loop on null timer doing > nothing!?! It sounds like this is a bug in the wrapper. I am no python expert, but I think the wrapper should give up the GIL before calling dispatch and grab it again before it calls back into python.
Probably something like that. But it's not that easy, because it has to release the GIL before dispatch, but dispatch itself will call other python codes which should grab it before execution and release it before going back to dispatch ... but same for me: not a python expert! -khc
_______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users