While playing with pyevent, I saw this code:
def abort():
"""Abort event dispatch loop."""
cdef extern int event_gotsig
cdef extern int (*event_sigcb)()
event_sigcb = __event_sigcb
event_gotsig = 1
This is used in exception handling - if a callback throws an exception,
it does this to propogate the exception through immediately (breaking
out of the loop without running any more callbacks).
This off-label use of a deprecated libevent interface is confusing, and
I suspect it can interact badly with the more modern signal handling
interface.
I propose instead that libevent have a event_base_loop_break() and
event_loop_break(). (Or whatever you want them called.) They'd differ
from event_{base_,}loop_exit() in that they would *immediately* abort
the loop without finishing the iteration (i.e., sooner than
event_base_loop_exit({.tv_sec=0, .tv_usec=0})). They'd be analogous to
the C "break;" statement. Like event_loop_exit(), the next dispatch
would be unaffected.
Feelings? I'd be happy to work up a patch and unit test.
Best regards,
Scott
[1] - Well, not quite, because there's a bug.
<http://code.google.com/p/pyevent/issues/detail?id=6> But it's clearly
intended to, and with a small patch it does.
--
Scott Lamb <http://www.slamb.org/>
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users