#NEWLINE# def readAsync( self , max = None , min = 1 ) : #NEWLINE# #INDENT# 'Start a read operation on the TLS connection.\n\n        This function returns a generator which behaves similarly to\n        read().  Successive invocations of the generator will return 0\n        if it is waiting to read from the socket, 1 if it is waiting\n        to write to the socket, or a string if the read operation has\n        completed.\n\n        @rtype: iterable\n        @return: A generator; see above for details.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# while ( ( len ( self . _readBuffer ) < min ) and ( not self . closed ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# for result in self . _getMsg ( ContentType . application_data ) : #NEWLINE# #INDENT# if ( result in ( 0 , 1 ) ) : #NEWLINE# #INDENT# ( yield result ) #NEWLINE# #UNINDENT# #UNINDENT# applicationData = result #NEWLINE# self . _readBuffer += bytesToString ( applicationData . write ( ) ) #NEWLINE# #UNINDENT# except TLSRemoteAlert as alert : #NEWLINE# #INDENT# if ( alert . description != AlertDescription . close_notify ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# except TLSAbruptCloseError : #NEWLINE# #INDENT# if ( not self . ignoreAbruptClose ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _shutdown ( True ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( max == None ) : #NEWLINE# #INDENT# max = len ( self . _readBuffer ) #NEWLINE# #UNINDENT# returnStr = self . _readBuffer [ : max ] #NEWLINE# self . _readBuffer = self . _readBuffer [ max : ] #NEWLINE# ( yield returnStr ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# self . _shutdown ( False ) #NEWLINE# raise