Merge lp:~mbp/bzr-email/242262-mail-deadlock into lp:bzr-email

Proposed by Martin Pool
Status: Merged
Merged at revision: 46
Proposed branch: lp:~mbp/bzr-email/242262-mail-deadlock
Merge into: lp:bzr-email
Diff against target: None lines
To merge this branch: bzr merge lp:~mbp/bzr-email/242262-mail-deadlock
Reviewer Review Type Date Requested Status
Robert Collins Pending
Review via email: mp+4430@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

try again?

Revision history for this message
Martin Pool (mbp) wrote :

ping?

Revision history for this message
Robert Collins (lifeless) wrote :

Your branch needs to be upgraded - I can't see a clicky clicky button to do it, maybe you can?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'emailer.py'
2--- emailer.py 2008-09-25 10:19:27 +0000
3+++ emailer.py 2008-11-27 02:10:14 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
6+# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10@@ -16,6 +16,7 @@
11
12 import errno
13 import subprocess
14+import tempfile
15
16 from bzrlib import (
17 errors,
18@@ -189,30 +190,21 @@
19 """Spawn a 'mail' subprocess to send the email."""
20 # TODO think up a good test for this, but I think it needs
21 # a custom binary shipped with. RBC 20051021
22+ msgfile = tempfile.NamedTemporaryFile()
23 try:
24+ msgfile.write(self.body().encode('utf8'))
25+ msgfile.write(self.get_diff())
26+ msgfile.flush()
27+ msgfile.seek(0)
28+
29 process = subprocess.Popen(self._command_line(),
30- stdin=subprocess.PIPE)
31- try:
32- message = self.body().encode('utf8') + self.get_diff()
33- result = process.communicate(message)[0]
34- if process.returncode is None:
35- process.wait()
36- if process.returncode != 0:
37- raise errors.BzrError("Failed to send email")
38- return result
39- except OSError, e:
40- if e.errno == errno.EPIPE:
41- raise errors.BzrError("Failed to send email.")
42- else:
43- raise
44- except ValueError:
45- # bad subprocess parameters, should never happen.
46- raise
47- except OSError, e:
48- if e.errno == errno.ENOENT:
49- raise errors.BzrError("mail is not installed !?")
50- else:
51- raise
52+ stdin=msgfile.fileno())
53+
54+ rc = process.wait()
55+ if rc != 0:
56+ raise errors.BzrError("Failed to send email: exit status %s" % (rc,))
57+ finally:
58+ msgfile.close()
59
60 def _send_using_smtplib(self):
61 """Use python's smtplib to send the email."""

Subscribers

People subscribed via source and target branches

to all changes: