From dd865104978471af4ad8d09490c6c42873dba926 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 13 Aug 2010 12:33:48 -0700 Subject: [PATCH] Handle KeyError due to stale events. --- pym/_emerge/PollScheduler.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index 704ddc317..ea8ebaacf 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -161,9 +161,13 @@ class PollScheduler(object): try: while event_handlers and self._poll_event_queue: f, event = self._next_poll_event() - handler, reg_id = event_handlers[f] - handler(f, event) - events_handled += 1 + try: + handler, reg_id = event_handlers[f] + except KeyError: + pass + else: + handler(f, event) + events_handled += 1 except StopIteration: events_handled += 1 @@ -210,9 +214,13 @@ class PollScheduler(object): try: while wait_ids.intersection(handler_ids): f, event = self._next_poll_event(timeout=timeout) - handler, reg_id = event_handlers[f] - handler(f, event) - event_handled = True + try: + handler, reg_id = event_handlers[f] + except KeyError: + pass + else: + handler(f, event) + event_handled = True if timeout is not None: if 1000 * time.time() - start_time >= timeout: break -- 2.26.2