1 |
Author: zmedico |
2 |
Date: 2008-03-29 07:06:28 +0000 (Sat, 29 Mar 2008) |
3 |
New Revision: 9600 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/pym/elog_modules/mod_mail_summary.py |
7 |
Log: |
8 |
Bug #215240 - Use an alarm signal to implement a 60 second timeout in |
9 |
finalize() in case send_mail() blocks indefinitely. (trunk r9588) |
10 |
|
11 |
|
12 |
Modified: main/branches/2.1.2/pym/elog_modules/mod_mail_summary.py |
13 |
=================================================================== |
14 |
--- main/branches/2.1.2/pym/elog_modules/mod_mail_summary.py 2008-03-29 07:03:05 UTC (rev 9599) |
15 |
+++ main/branches/2.1.2/pym/elog_modules/mod_mail_summary.py 2008-03-29 07:06:28 UTC (rev 9600) |
16 |
@@ -51,8 +51,19 @@ |
17 |
|
18 |
mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject, |
19 |
mybody, attachments=items.values()) |
20 |
+ |
21 |
+ def timeout_handler(signum, frame): |
22 |
+ raise PortageException("Timeout in finalize() for elog system 'mail_summary'") |
23 |
+ import signal |
24 |
+ signal.signal(signal.SIGALRM, timeout_handler) |
25 |
+ # Timeout after one minute in case send_mail() blocks indefinitely. |
26 |
+ signal.alarm(60) |
27 |
+ |
28 |
try: |
29 |
- portage_mail.send_mail(mysettings, mymessage) |
30 |
+ try: |
31 |
+ portage_mail.send_mail(mysettings, mymessage) |
32 |
+ finally: |
33 |
+ signal.alarm(0) |
34 |
except PortageException, e: |
35 |
writemsg("%s\n" % str(e), noiselevel=-1) |
36 |
|
37 |
|
38 |
-- |
39 |
gentoo-commits@l.g.o mailing list |