diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-02-16 22:29:17 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-02-16 22:29:17 -0800 |
commit | 8dd6814bd387ddfba484bf22c429103b885a58c6 (patch) | |
tree | 66875c97bc8b5fcd9ebab3422352310036d75608 | |
parent | ed9125487af39181bf3a00ba46a2bda7ea1d68d2 (diff) | |
download | portage-8dd6814bd387ddfba484bf22c429103b885a58c6.tar.gz portage-8dd6814bd387ddfba484bf22c429103b885a58c6.tar.bz2 portage-8dd6814bd387ddfba484bf22c429103b885a58c6.zip |
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.
-rw-r--r-- | pym/portage/util/_eventloop/EventLoop.py | 7 |
1 files 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: |