class_docstr: A WebSocket connection.
  
  Call :meth:`connect` before :meth:`send` and :meth:`receive`.
  
  All methods are thread safe.
  
  Parameters
  ----------
  url
      The WebSocket URL.
      For tuner command channel it should be something like ``ws://localhost:8080/tuner``.
class_docstr_tok: ["A","WebSocket","connection",".","Call",":","meth",":","`","connect","`","before",":","meth",":","`","send","`","and",":","meth",":","`","receive","`",".","All","methods","are","thread","safe",".","Parameters","--","--","--","--","--","url","The","WebSocket","URL",".","For","tuner","command","channel","it","should","be","something","like","``","ws",":","\/\/localhost:8080\/tuner","``","."]
code: def terminate(self, reason: str | None = None) -> None:
      if self._ws is None:
          _logger.debug("terminate: No connection.")
          return
      self.disconnect(reason, 4001)
  
file_path: nni/nni/runtime/command_channel/websocket/connection.py
imports: from __future__ import annotations
  import asyncio
  import logging
  from threading import Lock, Thread
  from typing import Any, Type
  import websockets
  import nni
  from ..base import Command
label_desc: Use image node_id 4 for calling the WsConnection obj's underlying member method code with example usage: obj.terminate(reason) without return types