#NEWLINE# def respond( self , follow_up = True , **kwargs ) : #NEWLINE# #INDENT# "Send a response back to the peer\n        \n        Normally, a response requires another response from the peer until done=True. If follow_up==False, then we will not look for a response yet. This is used in action='wait' responses where we are going to send multiple responses in a row to the peer.\n        " #NEWLINE# if ( self [ 'type' ] == 'response' ) : #NEWLINE# #INDENT# assert ( self [ 'done' ] == False ) , "Can't respond to a response that is already marked done." #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# 'command_id' : self [ 'command_id' ] , #NEWLINE# 'type' : 'response' , #NEWLINE# #UNINDENT# } #NEWLINE# data . update ( self ) #NEWLINE# if ( not data . has_key ( 'done' ) ) : #NEWLINE# #INDENT# data [ 'done' ] = False #NEWLINE# #UNINDENT# data_str = json . dumps ( data , cls = JSONEncoder ) #NEWLINE# log . debug ( 'Sending response : {data}' . format ( data = data_str ) ) #NEWLINE# self . ws . send ( data_str ) #NEWLINE# if ( ( data [ 'done' ] == False ) and follow_up ) : #NEWLINE# #INDENT# return self . receive ( )