#NEWLINE# def close( self , code = 1000 , reason = '' ) : #NEWLINE# #INDENT# '\n        Initiate the closing handshake with the server.\n        ' #NEWLINE# if ( not reason . client_terminated ) : #NEWLINE# #INDENT# self . client_terminated = True #NEWLINE# self . _write ( self . stream . close ( code = code , reason = reason ) . single ( mask = True ) )