AbstractPollTask: log exceptional events
authorZac Medico <zmedico@gentoo.org>
Thu, 10 Mar 2011 05:46:17 +0000 (21:46 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 10 Mar 2011 05:55:11 +0000 (21:55 -0800)
Previously, when AbstractPollTask receives a POLLERR or POLLNVAL event,
it would silently cancel the task. Now it will generate a message like
this:

   !!! SpawnProcess received strange poll event: 8

The message is displayed via a new _log_poll_exception method, which
is overridden by AbstractEbuildProcess to log the message via elog.

This might help diagnose reported cases of SIGTERM signals killing
ebuild processes for no apparent reason:

   http://code.google.com/p/chromium-os/issues/detail?id=12968

pym/_emerge/AbstractEbuildProcess.py
pym/_emerge/AbstractPollTask.py

index 601aafe0e39ef2b5ad1d0fd4795645b69797257e..d7f31be288352b74a8387672609ecad7e98b5270 100644 (file)
@@ -228,6 +228,11 @@ class AbstractEbuildProcess(SpawnProcess):
                        self.scheduler.output(msg,
                                log_path=self.settings.get("PORTAGE_LOG_FILE"))
 
+       def _log_poll_exception(self, event):
+               self._elog("eerror",
+                       ["%s received strange poll event: %s\n" % \
+                       (self.__class__.__name__, event,)])
+
        def _set_returncode(self, wait_retval):
                SpawnProcess._set_returncode(self, wait_retval)
 
index 833ee3b4c95db0aa0eeafa9dcaeb03d788004379..6cbf984b98ca4eb12a3d53261eb2a4add3e0bea9 100644 (file)
@@ -1,8 +1,10 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import array
+import logging
 
+from portage.util import writemsg_level
 from _emerge.AsynchronousTask import AsynchronousTask
 from _emerge.PollConstants import PollConstants
 class AbstractPollTask(AsynchronousTask):
@@ -39,9 +41,16 @@ class AbstractPollTask(AsynchronousTask):
        def _unregister(self):
                raise NotImplementedError(self)
 
+       def _log_poll_exception(self, event):
+               writemsg_level(
+                       "!!! %s received strange poll event: %s\n" % \
+                       (self.__class__.__name__, event,),
+                       level=logging.ERROR, noiselevel=-1)
+
        def _unregister_if_appropriate(self, event):
                if self._registered:
                        if event & self._exceptional_events:
+                               self._log_poll_exception(event)
                                self._unregister()
                                self.cancel()
                        elif event & PollConstants.POLLHUP: