<s> """<STR_LIT>""" <EOL> import sys <EOL> import threading <EOL> from django . core . mail . backends . base import BaseEmailBackend <EOL> class EmailBackend ( BaseEmailBackend ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . stream = kwargs . pop ( '<STR_LIT>' , sys . stdout ) <EOL> self . _lock = threading . RLock ( ) <EOL> super ( EmailBackend , self ) . __init__ ( * args , ** kwargs ) <EOL> def send_messages ( self , email_messages ) : <EOL> """<STR_LIT>""" <EOL> if not email_messages : <EOL> return <EOL> self . _lock . acquire ( ) <EOL> try : <EOL> try : <EOL> stream_created = self . open ( ) <EOL> for message in email_messages : <EOL> self . stream . write ( '<STR_LIT>' % message . message ( ) . as_string ( ) ) <EOL> self . stream . write ( '<STR_LIT:->' * <NUM_LIT> ) <EOL> self . stream . write ( '<STR_LIT:\n>' ) <EOL> self . stream . flush ( ) <EOL> if stream_created : <EOL> self . close ( ) <EOL> except : <EOL> if not self . fail_silently : <EOL> raise <EOL> finally : <EOL> self . _lock . release ( ) <EOL> return len ( email_messages ) </s>
