|
From: Nathan H. <hj...@me...> - 2012-12-13 15:56:47
|
On Dec 11, 2012, at 02:41 PM, Vincent Pelletier <plr...@gm...> wrote: (re-sending a few mails, as list CC got lost) Le dimanche 09 décembre 2012 19:00:51, vous avez écrit : > Well, the latest python docs imply you would simply do the following in the > code you use to wrap libusb: > > PyGILState_STATE gstate;gstate = PyGILState_Ensure(); > /* Perform Python actions here. */result = CallSomeFunction();/* > evaluate result or handle exception */ > /* Release the thread. No Python API allowed beyond this point. > */PyGILState_Release(gstate); > > Why couldn't you do that? My libusb wrapper is written in pure python, using ctypes module to load libusb and defining needed structures. Actually, the extract you pasted is about GIL (Global Interpreter Lock) handling, which is properly done by ctypes. This works fine for libusb async transfer callbacks. This is different (in my understanding) from the issue of getting exception raised in a thread which python doesn't know about. At best, exception will be ignored (call stack would not start in python, but in libusb), and at worse it would crash even before entering the hotplug callback. I'll check more how this could be done on my side. Also, is there a place where I could fetch your code so I can test the actual behaviour ? I am planning on pushing a release candidate to my git repository some time this weekend. This is dependent on a number of factors but expect the code to be available by the 22nd at the very latest. -Nathan |