#NEWLINE# def run( self ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# logger . info ( ( 'Starting server on port %d' % self . port ) ) #NEWLINE# self . socket = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) #NEWLINE# self . socket . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) #NEWLINE# self . socket . bind ( ( self . hostname , self . port ) ) #NEWLINE# self . socket . listen ( self . backlog ) #NEWLINE# while True : #NEWLINE# #INDENT# ( conn , addr ) = self . socket . accept ( ) #NEWLINE# logger . debug ( ( 'Accepted connection %r at address %r' % ( conn , addr ) ) ) #NEWLINE# client = Client ( conn , addr ) #NEWLINE# self . handle ( conn ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logger . exception ( ( 'Exception while running the server %r' % e ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# logger . info ( 'Closing server socket' ) #NEWLINE# self . socket . close ( )