|
From: Vincent P. <plr...@gm...> - 2012-12-11 21:41:37
|
Le mardi 11 décembre 2012 18:08:48, Orin Eman a écrit :
> By outer python stack frame, do you mean your callback function? I'd
> expect you'd surround all the contents of your callback with try...except
> and not let any exceptions escape.
Looks like it's been longer than I thought that I had any exception raised
inside a callback... ctypes indeeds catches the exception and handles it
before going up to C code. For some reason I thought it would propagate to an
outer python frame (as in, python code calling libusb_handle_events, itself
calling python callback: exception never actually reaches code calling
libusb_handle_events).
Example:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "/home/vincent/git/python-libusb1/usb1.py", line 203, in
__callbackWrapper
callback(self)
File "/home/vincent/git/python-libusb1/usb1.py", line 612, in __call__
transfer):
File "./iti1480a/capture.py", line 97, in __call__
raise Exception('test')
Exception: test
(no mention of what came before _ctypes/callbacks.c)
So nevermind this "problem": I was just imagining things. Ctypes should be
handling threads initiated from C code just fine.
Regards,
--
Vincent Pelletier
|