#NEWLINE# def send_messages( self , email_messages ) : #NEWLINE# #INDENT# 'Write all messages to the stream in a thread-safe way.' #NEWLINE# if ( not email_messages ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# with stream_created . _lock : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# stream_created = self . open ( ) #NEWLINE# for message in email_messages : #NEWLINE# #INDENT# self . stream . write ( ( '%s\n' % message . message ( ) . as_string ( ) ) ) #NEWLINE# self . stream . write ( ( '-' * 79 ) ) #NEWLINE# self . stream . write ( '\n' ) #NEWLINE# self . stream . flush ( ) #NEWLINE# #UNINDENT# if stream_created : #NEWLINE# #INDENT# self . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# if ( not self . fail_silently ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return len ( email_messages )