autotest: don't attempt to install sigalrm handler in mod_wsgi processes
Installing custom signal handlers inside a mod_wsgi process is never
expected to work, as mod_wsgi relies on these signals for its own
purposes, and will intercept attempts to modify them (and emit spam to
the apache error log).
We can detect when running inside a mod_wsgi process, and not even
bother trying to install sigalrm handler in such a case.
Tested-by: Aviv Keshet <firstname.lastname@example.org>
Reviewed-by: Richard Barnette <email@example.com>
Commit-Queue: Aviv Keshet <firstname.lastname@example.org>
diff --git a/client/common_lib/cros/retry.py b/client/common_lib/cros/retry.py
index 0c8dffb..1b268e8 100644
@@ -11,6 +11,16 @@
from autotest_lib.client.common_lib import error
+_in_mod_wsgi = False
+ # Per mod_wsgi documentation, this import will only suceed if we are running
+ # inside a mod_wsgi process.
+ # pylint: disable=unused-import
+ from mod_wsgi import version
+ _in_mod_wsgi = True
@@ -26,6 +36,12 @@
the numbers 1,0 respectively.
@return: True if the installation of new_handler succeeded, False otherwise.
+ # Installing signal handlers does not and is never expected to work if we're
+ # running in a mod_wsgi process.
+ if _in_mod_wsgi:
+ logging.warning('Cannot install sigalarm handler in mod_wsgi process.')
+ return False
if (new_handler is None or
(not callable(new_handler) and
new_handler != signal.SIG_IGN and