From 8dd6814bd387ddfba484bf22c429103b885a58c6 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 16 Feb 2012 22:29:17 -0800 Subject: 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. --- pym/portage/util/_eventloop/EventLoop.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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: -- cgit v1.2.3-1-g7c22