summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-29 03:40:32 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-29 03:40:32 +0000
commit996c8e189b7b72737d7e6dcc4fc4168013bf6783 (patch)
treea547d5d59f1411b47232b370a196efb8f45def57
parentbb93af369a622d63cbfd7746f51e014ce4952215 (diff)
downloadportage-996c8e189b7b72737d7e6dcc4fc4168013bf6783.tar.gz
portage-996c8e189b7b72737d7e6dcc4fc4168013bf6783.tar.bz2
portage-996c8e189b7b72737d7e6dcc4fc4168013bf6783.zip
Bug #215240 - Use an alarm signal to implement a 60 second timeout in
finalize() in case send_mail() blocks indefinitely. svn path=/main/trunk/; revision=9588
-rw-r--r--pym/portage/elog/mod_mail_summary.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/pym/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py
index 40a2484a6..8f7f86217 100644
--- a/pym/portage/elog/mod_mail_summary.py
+++ b/pym/portage/elog/mod_mail_summary.py
@@ -51,8 +51,19 @@ def _finalize(mysettings, items):
mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject,
mybody, attachments=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:
- portage.mail.send_mail(mysettings, mymessage)
+ try:
+ portage.mail.send_mail(mysettings, mymessage)
+ finally:
+ signal.alarm(0)
except PortageException, e:
writemsg("%s\n" % str(e), noiselevel=-1)