From: Zac Medico Date: Sat, 5 Sep 2009 01:26:36 +0000 (-0000) Subject: Bug #282808 - Handle a potential KeyError inside PollScheduler._poll_loop() X-Git-Tag: v2.2_rc41~77 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7cdad53557e97b101213e93a3cf9b723edb0740d;p=portage.git Bug #282808 - Handle a potential KeyError inside PollScheduler._poll_loop() when _poll_event_queue contains an event for a file descriptor that has already been unregistered. svn path=/main/trunk/; revision=14185 --- diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index 3733af45b..8250cb00a 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -123,7 +123,14 @@ class PollScheduler(object): try: while event_handlers: f, event = self._next_poll_event() - handler, reg_id = event_handlers[f] + try: + handler, reg_id = event_handlers[f] + except KeyError: + # This means unregister was called for a file descriptor + # that still had a pending event in _poll_event_queue. + # Since unregister has been called, we should assume that + # the event can be safely ignored. + continue handler(f, event) event_handled = True except StopIteration: