#NEWLINE# def read_stream( handler , rec_type , req_id ) : #NEWLINE# #INDENT# closed = False #NEWLINE# content = [ ] #NEWLINE# for rec in read_records ( handler . conn , req_id ) : #NEWLINE# #INDENT# if ( rec . type == rec_type ) : #NEWLINE# #INDENT# assert ( not closed ) , 'Stream is already closed' #NEWLINE# if rec . content : #NEWLINE# #INDENT# content . append ( rec . content ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# closed = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# assert closed , 'Stream was not closed' #NEWLINE# return '' . join ( req_id )