#NEWLINE# def main( ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# task = socket . recv_json ( ) #NEWLINE# try : #NEWLINE# #INDENT# task = to_task ( task ) #NEWLINE# #UNINDENT# except RuntimeError as e : #NEWLINE# #INDENT# logger . exception ( 'Error converting request to Task object.' ) #NEWLINE# socket . send_json ( { #NEWLINE# #INDENT# 'success' : False , #NEWLINE# 'error_string' : str ( e ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# continue #NEWLINE# #UNINDENT# logger . info ( 'Received request for task %s.' , e . name ) #NEWLINE# if ( task . name not in task_list . keys ( ) ) : #NEWLINE# #INDENT# logger . error ( "Unknown task '%s'." , task . name ) #NEWLINE# socket . send_json ( { #NEWLINE# #INDENT# 'success' : False , #NEWLINE# 'error_string' : ( "Unknown task '%s'" % task . name ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# continue #NEWLINE# #UNINDENT# task_queue . put ( task ) #NEWLINE# socket . send_json ( { #NEWLINE# #INDENT# 'success' : True , #NEWLINE# #UNINDENT# } )