#NEWLINE# def run( self ) : #NEWLINE# #INDENT# "The socket thread's run loop." #NEWLINE# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# self . log . info ( 'Waiting for a connection...' ) #NEWLINE# self . mc . events . post ( 'client_disconnected' ) #NEWLINE# self . mc . pc_connected = False #NEWLINE# ( self . connection , client_address ) = self . socket . accept ( ) #NEWLINE# self . log . info ( 'Received connection from: %s:%s' , client_address [ 0 ] , client_address [ 1 ] ) #NEWLINE# self . mc . events . post ( 'client_connected' , address = cmd [ 0 ] , port = client_address [ 1 ] ) #NEWLINE# self . mc . pc_connected = True #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# data = self . connection . recv ( 4096 ) #NEWLINE# if data : #NEWLINE# #INDENT# commands = data . split ( '\n' ) #NEWLINE# for cmd in commands : #NEWLINE# #INDENT# if cmd : #NEWLINE# #INDENT# self . process_received_message ( cmd ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# if self . mc . config [ 'media_controller' ] [ 'exit_on_disconnect' ] : #NEWLINE# #INDENT# self . mc . shutdown ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# ( exc_type , exc_value , exc_traceback ) = sys . exc_info ( ) #NEWLINE# lines = traceback . format_exception ( exc_type , exc_value , exc_traceback ) #NEWLINE# msg = '' . join ( ( line for line in lines ) ) #NEWLINE# self . mc . crash_queue . put ( msg )