public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_eventloop/
Date: Tue, 14 Feb 2012 03:06:52 +0000 (UTC)	[thread overview]
Message-ID: <1329188789.fe3960b69c326bc779bdf5ec34d56630b3e188ae.zmedico@gentoo> (raw)

commit:     fe3960b69c326bc779bdf5ec34d56630b3e188ae
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 14 03:06:29 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Feb 14 03:06:29 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fe3960b6

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
 
+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")
 
-		# 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=logging.ERROR, noiselevel=-1)
+				# Silently handle EINTR, which is normal when we have
+				# received a signal such as SIGINT.
+				if not (e.args and e.args[0] == errno.EINTR):
+					writemsg_level("\n!!! select error: %s\n" % (e,),
+						level=logging.ERROR, noiselevel=-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")
 
 	def _next_poll_event(self, timeout=None):
 		"""
@@ -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 += 1
 
 		try:



             reply	other threads:[~2012-02-14  3:07 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14  3:06 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-07-18  3:41 [gentoo-commits] proj/portage:master commit in: pym/portage/util/_eventloop/ Zac Medico
2018-07-17 19:27 Zac Medico
2018-07-17 19:07 Zac Medico
2018-06-27  3:05 Zac Medico
2018-05-26 20:22 Zac Medico
2018-05-25  3:15 Zac Medico
2018-05-13 16:58 Zac Medico
2018-05-07  0:27 Zac Medico
2018-04-19  6:41 Zac Medico
2018-04-19  6:16 Zac Medico
2018-04-18 21:52 Zac Medico
2018-04-17 18:24 Zac Medico
2018-04-17 18:02 Zac Medico
2018-04-17  6:24 Zac Medico
2018-04-17  0:53 Zac Medico
2018-04-16  8:48 Zac Medico
2018-04-16  6:43 Zac Medico
2018-04-16  0:03 Zac Medico
2018-04-15 22:32 Zac Medico
2018-04-09  1:27 Zac Medico
2018-04-08 22:08 Zac Medico
2018-04-08 21:37 Zac Medico
2018-04-08 21:18 Zac Medico
2018-04-07 20:20 Zac Medico
2017-05-05 18:47 Zac Medico
2013-02-25 23:53 Zac Medico
2013-01-04  3:39 Zac Medico
2012-12-31  3:16 Zac Medico
2012-12-28  1:44 Zac Medico
2012-12-28  1:36 Zac Medico
2012-12-27  2:39 Zac Medico
2012-12-27  2:31 Zac Medico
2012-11-22 12:23 Zac Medico
2012-09-26  2:26 Zac Medico
2012-08-22 16:23 Zac Medico
2012-08-22  5:39 Zac Medico
2012-02-18  4:04 Zac Medico
2012-02-17 23:23 Zac Medico
2012-02-17 22:17 Zac Medico
2012-02-17 10:31 Zac Medico
2012-02-17 10:20 Zac Medico
2012-02-17  9:29 Zac Medico
2012-02-17  6:29 Zac Medico
2012-02-17  6:04 Zac Medico
2012-02-17  3:08 Zac Medico
2012-02-16 21:43 Zac Medico
2012-02-16 21:35 Zac Medico
2012-02-16  4:58 Zac Medico
2012-02-16  4:41 Zac Medico
2012-02-14 16:27 Zac Medico
2012-02-14  1:23 Zac Medico
2012-02-11 23:56 Zac Medico
2012-02-11 21:41 Zac Medico
2012-02-11 21:11 Zac Medico
2012-02-11 19:35 Zac Medico
2012-02-11  2:59 Zac Medico
2012-02-10  0:42 Zac Medico
2012-02-10  0:20 Zac Medico
2012-02-10  0:17 Zac Medico
2012-02-09  7:25 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329188789.fe3960b69c326bc779bdf5ec34d56630b3e188ae.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox