~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to django/core/mail/backends/console.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2014-09-17 14:15:11 UTC
  • mfrom: (1.3.17) (6.2.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140917141511-icneokthe9ww5sk4
Tags: 1.7-2
* Release to unstable.
* Add a migrate-south sample script to help users apply their South
  migrations. Thanks to Brian May.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from django.core.mail.backends.base import BaseEmailBackend
8
8
from django.utils import six
9
9
 
 
10
 
10
11
class EmailBackend(BaseEmailBackend):
11
12
    def __init__(self, *args, **kwargs):
12
13
        self.stream = kwargs.pop('stream', sys.stdout)
27
28
        """Write all messages to the stream in a thread-safe way."""
28
29
        if not email_messages:
29
30
            return
 
31
        msg_count = 0
30
32
        with self._lock:
31
33
            try:
32
34
                stream_created = self.open()
33
35
                for message in email_messages:
34
36
                    self.write_message(message)
35
37
                    self.stream.flush()  # flush after each message
 
38
                    msg_count += 1
36
39
                if stream_created:
37
40
                    self.close()
38
 
            except:
 
41
            except Exception:
39
42
                if not self.fail_silently:
40
43
                    raise
41
 
        return len(email_messages)
 
44
        return msg_count