diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-09-03 18:05:12 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-03 18:05:12 -0700 |
commit | acedc2bc6262eb16a376cd5d30316712e8a5a097 (patch) | |
tree | ad5cedfb4e9b196288b6494a81d5d4cbcf80ca87 | |
parent | f0e30a093a082409a1145dea0a7785be8d2b1c21 (diff) | |
download | portage-acedc2bc6262eb16a376cd5d30316712e8a5a097.tar.gz portage-acedc2bc6262eb16a376cd5d30316712e8a5a097.tar.bz2 portage-acedc2bc6262eb16a376cd5d30316712e8a5a097.zip |
Use AlarmSignal for timeout handling in elog_process().
-rw-r--r-- | pym/portage/elog/__init__.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py index f1f2aea0c..a26fa57a2 100644 --- a/pym/portage/elog/__init__.py +++ b/pym/portage/elog/__init__.py @@ -8,7 +8,7 @@ portage.proxy.lazyimport.lazyimport(globals(), ) from portage.const import EBUILD_PHASES -from portage.exception import PortageException +from portage.exception import AlarmSignal, PortageException from portage.process import atexit_register from portage.elog.messages import collect_ebuild_messages, collect_messages from portage.elog.filtering import filter_loglevels @@ -153,17 +153,13 @@ def elog_process(cpv, mysettings, phasefilter=None): s = s.replace("-", "_") try: m = _load_mod("portage.elog.mod_" + s) - def timeout_handler(signum, frame): - raise PortageException("Timeout in elog_process for system '%s'" % s) - import signal - signal.signal(signal.SIGALRM, timeout_handler) # Timeout after one minute (in case something like the mail # module gets hung). - signal.alarm(60) try: + AlarmSignal.register(60) m.process(mysettings, str(key), mod_logentries, mod_fulllog) finally: - signal.alarm(0) + AlarmSignal.unregister() if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers: _elog_atexit_handlers.append(m.finalize) atexit_register(m.finalize) @@ -171,6 +167,9 @@ def elog_process(cpv, mysettings, phasefilter=None): writemsg(_("!!! Error while importing logging modules " "while loading \"mod_%s\":\n") % str(s)) writemsg("%s\n" % str(e), noiselevel=-1) + except AlarmSignal: + writemsg("Timeout in elog_process for system '%s'\n" % s, + noiselevel=-1) except PortageException as e: writemsg("%s\n" % str(e), noiselevel=-1) |