Write all messages to the stream in a thread-safe way.
(self, email_messages)
| 27 | self.stream.write("\n") |
| 28 | |
| 29 | def send_messages(self, email_messages): |
| 30 | """Write all messages to the stream in a thread-safe way.""" |
| 31 | if not email_messages: |
| 32 | return |
| 33 | msg_count = 0 |
| 34 | with self._lock: |
| 35 | try: |
| 36 | stream_created = self.open() |
| 37 | for message in email_messages: |
| 38 | self.write_message(message) |
| 39 | self.stream.flush() # flush after each message |
| 40 | msg_count += 1 |
| 41 | if stream_created: |
| 42 | self.close() |
| 43 | except Exception: |
| 44 | if not self.fail_silently: |
| 45 | raise |
| 46 | return msg_count |
nothing calls this directly
no test coverage detected