#NEWLINE# def read( self , max_bytes ) : #NEWLINE# #INDENT# 'Reads at most max_bytes, called by the UntarThread.' #NEWLINE# with self . cv : #NEWLINE# #INDENT# while ( not self . buf ) : #NEWLINE# #INDENT# if self . closed : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# self . cv . wait ( ) #NEWLINE# #UNINDENT# if ( len ( self . buf [ 0 ] ) <= max_bytes ) : #NEWLINE# #INDENT# return self . buf . pop ( 0 ) #NEWLINE# #UNINDENT# ret = self . buf [ 0 ] [ : max_bytes ] #NEWLINE# self . buf [ 0 ] = self . buf [ 0 ] [ ret : ] #NEWLINE# return ret