diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-02-14 08:27:01 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-02-14 08:27:01 -0800 |
commit | 608c76a4eb76b88221ba24ca1765765bef827fe1 (patch) | |
tree | 13f95299d6df0f6db6457539b12e7074b82c8142 | |
parent | a75341bf3a66f75edd68d1a8bc5efdb51c0c0740 (diff) | |
download | portage-608c76a4eb76b88221ba24ca1765765bef827fe1.tar.gz portage-608c76a4eb76b88221ba24ca1765765bef827fe1.tar.bz2 portage-608c76a4eb76b88221ba24ca1765765bef827fe1.zip |
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.
-rw-r--r-- | pym/portage/util/_eventloop/EventLoop.py | 17 |
1 files 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 |