#NEWLINE# def consume_socket_content( sock , timeout = 0.5 ) : #NEWLINE# #INDENT# chunks = 65536 #NEWLINE# content = b'' #NEWLINE# more_to_read = select . select ( [ sock ] , [ ] , [ ] , timeout ) [ 0 ] #NEWLINE# while more_to_read : #NEWLINE# #INDENT# new_content = sock . recv ( chunks ) #NEWLINE# if ( not new_content ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# content += new_content #NEWLINE# more_to_read = select . select ( [ new_content ] , [ ] , [ ] , timeout ) [ 0 ] #NEWLINE# #UNINDENT# return content