From: Zac Medico <zmedico@gentoo.org>
Date: Fri, 13 Aug 2010 19:33:48 +0000 (-0700)
Subject: Handle KeyError due to stale events.
X-Git-Tag: v2.2_rc68~235
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dd865104978471af4ad8d09490c6c42873dba926;p=portage.git

Handle KeyError due to stale events.
---

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