#NEWLINE# def message_return( self , msg_id , payload ) : #NEWLINE# #INDENT# ( handler , call_back_into_ui_thread , req_time ) = self . handlers . get ( msg_id ) #NEWLINE# if handler : #NEWLINE# #INDENT# del self . handlers [ msg_id ] #NEWLINE# #UNINDENT# def invoke_subscribed_handler( success , payload = None ) : #NEWLINE# #INDENT# if isinstance ( handler , collections . Callable ) : #NEWLINE# #INDENT# if ( call_back_into_ui_thread and success ) : #NEWLINE# #INDENT# sublime . set_timeout ( bind ( handler , payload ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# handler ( payload ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# handler . payload = payload #NEWLINE# handler . set ( ) #NEWLINE# #UNINDENT# #UNINDENT# resp_time = time . time ( ) #NEWLINE# self . logger . info ( ( ( ( ( 'request #' + str ( msg_id ) ) + ' took ' ) + str ( ( resp_time - req_time ) ) ) + ' seconds' ) ) #NEWLINE# reply_type = str ( payload [ 0 ] ) #NEWLINE# if ( call_back_into_ui_thread == ':ok' ) : #NEWLINE# #INDENT# payload = payload [ 1 ] #NEWLINE# if handler : #NEWLINE# #INDENT# invoke_subscribed_handler ( success = True , payload = payload ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . warn ( ( ( ( 'warning: no handler registered for message #' + str ( msg_id ) ) + ' with payload ' ) + str ( payload ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( reply_type == ':abort' ) : #NEWLINE# #INDENT# detail = payload [ 2 ] #NEWLINE# if ( msg_id <= 1 ) : #NEWLINE# #INDENT# self . error_message ( self . prettify_error_detail ( detail ) ) #NEWLINE# self . status_message ( 'Ensime startup has failed' ) #NEWLINE# self . env . controller . shutdown ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# invoke_subscribed_handler ( success = False ) #NEWLINE# self . status_message ( detail ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( reply_type == ':error' ) : #NEWLINE# #INDENT# detail = payload [ 2 ] #NEWLINE# invoke_subscribed_handler ( success = False ) #NEWLINE# self . error_message ( self . prettify_error_detail ( detail ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# invoke_subscribed_handler ( success = False ) #NEWLINE# self . logger . warn ( ( 'unexpected reply type: ' + reply_type ) )