#NEWLINE# def handle_write( self ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# with self . deque_lock : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# next_msg = self . deque . popleft ( ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# self . _writable = False #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# sent = self . send ( next_msg ) #NEWLINE# self . _readable = True #NEWLINE# #UNINDENT# except socket . error as err : #NEWLINE# #INDENT# if ( err . args [ 0 ] in NONBLOCKING ) : #NEWLINE# #INDENT# with self . deque_lock : #NEWLINE# #INDENT# self . deque . appendleft ( self ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . defunct ( err ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( sent < len ( next_msg ) ) : #NEWLINE# #INDENT# with self . deque_lock : #NEWLINE# #INDENT# self . deque . appendleft ( next_msg [ sent : ] ) #NEWLINE# #UNINDENT# if ( sent == 0 ) : #NEWLINE# #INDENT# return