#NEWLINE# def receive( self ) : #NEWLINE# #INDENT# "\n        Perform non blocking read on  socket.\n\n        returns tuple of form (data, sa)\n        if no data then returns (b'',None)\n        but always returns a tuple with two elements\n        " #NEWLINE# try : #NEWLINE# #INDENT# ( data , sa ) = self . ss . recvfrom ( self . bs ) #NEWLINE# #UNINDENT# except socket . error as ex : #NEWLINE# #INDENT# if ( ex . errno in ( errno . EAGAIN , errno . EWOULDBLOCK ) ) : #NEWLINE# #INDENT# return ( b'' , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# emsg = 'socket.error = {0}: receiving at {1}\n' . format ( ex , self . ha ) #NEWLINE# console . profuse ( emsg ) #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# if ( console . _verbosity >= console . Wordage . profuse ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# load = data . decode ( 'UTF-8' ) #NEWLINE# #UNINDENT# except UnicodeDecodeError as ex : #NEWLINE# #INDENT# load = '0x{0}' . format ( hexlify ( data ) . decode ( 'ASCII' ) ) #NEWLINE# #UNINDENT# cmsg = '\nServer at {0}, received from {1}:\n------------\n{2}\n' . format ( self . ha , sa , load ) #NEWLINE# console . profuse ( cmsg ) #NEWLINE# #UNINDENT# if self . wlog : #NEWLINE# #INDENT# self . wlog . writeRx ( sa , data ) #NEWLINE# #UNINDENT# return ( data , sa )