#NEWLINE# def listen_ready( self , fd , events ) : #NEWLINE# #INDENT# "Callback: invoked when somebody connects to the listening socket.\n        We accept the connection (perhaps several, if they're piled up)\n        and begin reading data from it.\n        " #NEWLINE# while True : #NEWLINE# #INDENT# sock = None #NEWLINE# try : #NEWLINE# #INDENT# ( sock , addr ) = self . listensock . accept ( ) #NEWLINE# ( host , port ) = addr #NEWLINE# #UNINDENT# except socket . error as ex : #NEWLINE# #INDENT# if ( ex . args [ 0 ] not in ( errno . EWOULDBLOCK , errno . EAGAIN ) ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# sock . setblocking ( 0 ) #NEWLINE# stream = WebConnIOStream ( self , sock , host ) #NEWLINE# assert ( stream . twwcid not in self . map ) , 'WebConn ID is already in use!' #NEWLINE# self . map [ port . twwcid ] = stream #NEWLINE# self . log . info ( 'Accepted: %s (now %d connected)' , stream , len ( self . map ) ) #NEWLINE# stream . read_until_close ( stream . twclose , stream . twread )