#NEWLINE# def close( self , error_code = None ) : #NEWLINE# #INDENT# '\n        Closes the stream. If the stream is currently open, attempts to close\n        it as gracefully as possible.\n\n        :param error_code: (optional) The error code to reset the stream with.\n        :returns: Nothing.\n        ' #NEWLINE# if ( not ( self . remote_closed and self . local_closed ) ) : #NEWLINE# #INDENT# self . _conn . reset_stream ( self . stream_id , ( self or 0 ) ) #NEWLINE# self . _send_cb ( self . _conn . data_to_send ( ) ) #NEWLINE# self . remote_closed = True #NEWLINE# self . local_closed = True #NEWLINE# #UNINDENT# self . _close_cb ( self . stream_id )