From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Rx8jN-0004Xq-GA for garchives@archives.gentoo.org; Tue, 14 Feb 2012 03:07:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7D995E08F8; Tue, 14 Feb 2012 03:06:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3FB83E08F8 for ; Tue, 14 Feb 2012 03:06:54 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A48C71B400E for ; Tue, 14 Feb 2012 03:06:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 62B91E53FD for ; Tue, 14 Feb 2012 03:06:52 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1329188789.fe3960b69c326bc779bdf5ec34d56630b3e188ae.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_eventloop/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/_eventloop/EventLoop.py X-VCS-Directories: pym/portage/util/_eventloop/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: fe3960b69c326bc779bdf5ec34d56630b3e188ae X-VCS-Branch: master Date: Tue, 14 Feb 2012 03:06:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 376531b7-e51b-40d4-8578-3595bde6b8b8 X-Archives-Hash: c2466a60b211c4447fc8132dc810054a commit: fe3960b69c326bc779bdf5ec34d56630b3e188ae Author: Zac Medico gentoo org> AuthorDate: Tue Feb 14 03:06:29 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Feb 14 03:06:29 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dfe3960b6 EventLoop._do_poll: tweak EINTR handling Silently handle EINTR, which is normal when we have received a signal such as SIGINT. Also, raise StopIteration in order to break out of our current iteration and respond appropriately to the signal as soon as possible. --- pym/portage/util/_eventloop/EventLoop.py | 27 ++++++++++++++----------= --- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/= _eventloop/EventLoop.py index 6c6a1b7..37839ab 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -1,6 +1,7 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 +import errno import logging import select import time @@ -100,24 +101,23 @@ class EventLoop(object): raise StopIteration( "timeout is None and there are no poll() event handlers") =20 - # The following error is known to occur with Linux kernel versions - # less than 2.6.24: - # - # select.error: (4, 'Interrupted system call') - # - # This error has been observed after a SIGSTOP, followed by SIGCONT. - # Treat it similar to EAGAIN if timeout is None, otherwise just return - # without any events. while True: try: self._poll_event_queue.extend(self._poll_obj.poll(timeout)) break except select.error as e: - writemsg_level("\n!!! select error: %s\n" % (e,), - level=3Dlogging.ERROR, noiselevel=3D-1) + # Silently handle EINTR, which is normal when we have + # received a signal such as SIGINT. + if not (e.args and e.args[0] =3D=3D errno.EINTR): + writemsg_level("\n!!! select error: %s\n" % (e,), + level=3Dlogging.ERROR, noiselevel=3D-1) del e - if timeout is not None: - break + + # This typically means that we've received a SIGINT, so + # raise StopIteration in order to break out of our current + # iteration and respond appropriately to the signal as soon + # as possible. + raise StopIteration("interrupted") =20 def _next_poll_event(self, timeout=3DNone): """ @@ -170,7 +170,8 @@ class EventLoop(object): 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. + # being removed by timeout or idle callbacks. It can + # also be triggered by EINTR which is caused by signals. events_handled +=3D 1 =20 try: