From 608c76a4eb76b88221ba24ca1765765bef827fe1 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 14 Feb 2012 08:27:01 -0800 Subject: EventLoop: allow IO event handler re-entrance IO event handlers may be re-entrant, in case something like AbstractPollTask._wait_loop(), needs to be called inside a handler for some reason. --- pym/portage/util/_eventloop/EventLoop.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py index 37839ab2d..af0c6a502 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -20,7 +20,7 @@ class EventLoop(object): __slots__ = ("args", "callback", "calling", "source_id") class _io_handler_class(SlotObject): - __slots__ = ("args", "callback", "calling", "fd", "source_id") + __slots__ = ("args", "callback", "fd", "source_id") class _timeout_handler_class(SlotObject): __slots__ = ("args", "function", "calling", "interval", "source_id", @@ -178,16 +178,11 @@ class EventLoop(object): while event_handlers and self._poll_event_queue: f, event = self._next_poll_event() x = event_handlers[f] - if x.calling: - # don't call it recursively - continue - events_handled += 1 - x.calling = True - try: - if not x.callback(f, event, *x.args): - self.source_remove(x.source_id) - finally: - x.calling = False + # NOTE: IO event handlers may be re-entrant, in case something + # like AbstractPollTask._wait_loop(), needs to be called inside + # a handler for some reason. + if not x.callback(f, event, *x.args): + self.source_remove(x.source_id) except StopIteration: events_handled += 1 -- cgit v1.2.3-1-g7c22