code: def keep_alive(self, val: bool) -> None:
          
          self._keepalive = val
          if self._keepalive_handle:
              self._keepalive_handle.cancel()
              self._keepalive_handle = None
docs: Set keep-alive connection mode.
  
          :param bool val: new state.