summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-15 16:35:20 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-15 16:35:20 -0700
commit2e81650c86d619008e9db0b1a649c1c5dff14480 (patch)
tree33db27eb0a37a3d595afbad0b73d17a165eedf66
parent0562ac6f03894e1f9450b0ec426d6c4737de6488 (diff)
downloadportage-2e81650c86d619008e9db0b1a649c1c5dff14480.tar.gz
portage-2e81650c86d619008e9db0b1a649c1c5dff14480.tar.bz2
portage-2e81650c86d619008e9db0b1a649c1c5dff14480.zip
Don't handle KeyError when looking up event handlers, since
_unregister() automatically discards stale events now.
-rw-r--r--pym/_emerge/PollScheduler.py43
1 files changed, 12 insertions, 31 deletions
diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py
index 738dcc7f1..ce971282f 100644
--- a/pym/_emerge/PollScheduler.py
+++ b/pym/_emerge/PollScheduler.py
@@ -126,14 +126,7 @@ class PollScheduler(object):
try:
while event_handlers:
f, event = self._next_poll_event()
- 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, reg_id = event_handlers[f]
handler(f, event)
event_handled = True
except StopIteration:
@@ -162,13 +155,9 @@ class PollScheduler(object):
try:
while event_handlers and self._poll_event_queue:
f, event = self._next_poll_event()
- try:
- handler, reg_id = event_handlers[f]
- except KeyError:
- pass
- else:
- handler(f, event)
- events_handled += 1
+ handler, reg_id = event_handlers[f]
+ handler(f, event)
+ events_handled += 1
except StopIteration:
events_handled += 1
@@ -228,13 +217,9 @@ class PollScheduler(object):
try:
while wait_ids.intersection(handler_ids):
f, event = self._next_poll_event(timeout=timeout)
- try:
- handler, reg_id = event_handlers[f]
- except KeyError:
- pass
- else:
- handler(f, event)
- event_handled = True
+ handler, reg_id = event_handlers[f]
+ handler(f, event)
+ event_handled = True
if timeout is not None:
if 1000 * time.time() - start_time >= timeout:
break
@@ -258,15 +243,11 @@ class PollScheduler(object):
try:
while event_handlers:
f, event = self._next_poll_event()
- try:
- handler, reg_id = event_handlers[f]
- except KeyError:
- pass
- else:
- handler(f, event)
- wait_retval = os.waitpid(pid, os.WNOHANG)
- if wait_retval != (0, 0):
- return wait_retval
+ handler, reg_id = event_handlers[f]
+ handler(f, event)
+ wait_retval = os.waitpid(pid, os.WNOHANG)
+ if wait_retval != (0, 0):
+ return wait_retval
self._schedule()
except StopIteration:
pass