diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-09-03 18:19:16 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-03 18:19:16 -0700 |
commit | 36e310228280be6d662677f3cfe5bba1e71d4dfd (patch) | |
tree | 128264d24efac918aae59f102109b1f055ce04a0 | |
parent | 22ee35ed55d8b89340bda893e3951d3125e8369c (diff) | |
download | portage-36e310228280be6d662677f3cfe5bba1e71d4dfd.tar.gz portage-36e310228280be6d662677f3cfe5bba1e71d4dfd.tar.bz2 portage-36e310228280be6d662677f3cfe5bba1e71d4dfd.zip |
Use AlarmSignal for timout handling in mod_mail_summary.finalize().
-rw-r--r-- | pym/portage/elog/mod_mail_summary.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/pym/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py index e739a7a7a..296144736 100644 --- a/pym/portage/elog/mod_mail_summary.py +++ b/pym/portage/elog/mod_mail_summary.py @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 import portage -from portage.exception import PortageException +from portage.exception import AlarmSignal from portage.localization import _ from portage.util import writemsg from portage import os @@ -57,19 +57,15 @@ def _finalize(mysettings, items): mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, mybody, attachments=list(items.values())) - def timeout_handler(signum, frame): - raise PortageException("Timeout in finalize() for elog system 'mail_summary'") - import signal - signal.signal(signal.SIGALRM, timeout_handler) # Timeout after one minute in case send_mail() blocks indefinitely. - signal.alarm(60) - try: try: + AlarmSignal.register(60) portage.mail.send_mail(mysettings, mymessage) finally: - signal.alarm(0) - except PortageException as e: - writemsg("%s\n" % str(e), noiselevel=-1) + AlarmSignal.unregister() + except AlarmSignal: + writemsg("Timeout in finalize() for elog system 'mail_summary'\n", + noiselevel=-1) return |