EventLoop.iteration: handle _poll StopIteration
authorZac Medico <zmedico@gentoo.org>
Sat, 11 Feb 2012 23:56:07 +0000 (15:56 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 11 Feb 2012 23:56:07 +0000 (15:56 -0800)
pym/portage/util/_eventloop/EventLoop.py

index c059197c17cfca3caf3dc1c8822f12e6e4a6b33d..0da388d03dbd2b91ce314296665472cdf009c59f 100644 (file)
@@ -177,7 +177,13 @@ class EventLoop(object):
                                timeout = self._timeout_interval
                        else:
                                timeout = 0
-                       self._poll(timeout=timeout)
+                       try:
+                               self._poll(timeout=timeout)
+                       except StopIteration:
+                               # This could happen if there are no IO event handlers
+                               # after _poll() calls _run_timeouts(), due to them
+                               # being removed by timeout or idle callbacks.
+                               events_handled += 1
 
                try:
                        while event_handlers and self._poll_event_queue: