From: Zac Medico Date: Fri, 17 Feb 2012 06:29:17 +0000 (-0800) Subject: EventLoop.iteration: poll for blocking, not sleep X-Git-Tag: v2.2.0_alpha87~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8dd6814bd387ddfba484bf22c429103b885a58c6;p=portage.git EventLoop.iteration: poll for blocking, not sleep The effect is be mostly the same, but it's more conistent to use _do_poll for all blocking, plus it has EINTR handling. --- diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py index 7f171fb8c..37a971e40 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -176,11 +176,14 @@ class EventLoop(object): if not event_handlers: if not events_handled and may_block and \ self._timeout_interval is not None: - # Sleep so that we don't waste cpu time by looping too + # Block so that we don't waste cpu time by looping too # quickly. This makes EventLoop useful for code that needs # to wait for timeout callbacks regardless of whether or # not any IO handlers are currently registered. - time.sleep(self._timeout_interval/1000) + try: + self._do_poll(timeout=self._timeout_interval) + except StopIteration: + pass if self._run_timeouts(): events_handled += 1 if not event_handlers: