[Pyrex] while loop not detecting ctrl-c
Bryan Weingarten
bryan.weingarten at pobox.com
Wed Nov 26 01:39:58 CET 2003
greg / anyone,
can anyone tell me if this issue can be solved? when Play.play() is
called and a callback parameter is specified, the user can do a ctrl-c
(on windows) and break out of the play. my guess why this works is that
the callback ends up in the python interpreter and the pyrex "except *"
is able to detect it with PyErr_Occurred(). but if callback is not
specified, the while loop never goes back to the python interpreter
during the loop and the ctrl-c doesn't get detected. as you can see
from the pyrex generated code, PyErr_Occurred is correctly being called
after each frame is played, so i'm at a loss.
thanks you for any help,
bryan
-----------
cdef extern from "playif.h":
int mpgedit_play_frame(void *ctx) except *
cdef class Play:
def play(self, callback=None):
self.callback = callback
if callback:
mpgedit_play_set_status_callback(self.ctx,
_callback_wrapper, <void*>callback)
while(mpgedit_play_frame(self.ctx)): pass
---------
generated c code for the while loop in Play.play()
while (1) {
__pyx_L3:;
__pyx_1 = mpgedit_play_frame(((struct __pyx_obj_7mpgedit_Play
*)__pyx_v_self)->ctx);
if (PyErr_Occurred()) {
__pyx_filename = __pyx_f[0];
__pyx_lineno = 95;
goto __pyx_L1;
}
if (!__pyx_1) break;
}
More information about the Pyrex
mailing list