original_docstring: Ping the socket to ensure it's alive & trigger latent disconnects.
  
      (This is done manually because Emacs seems to have dodgy support for TCP
      keepalive.)
  
      
docstring: Ping the socket to ensure it's alive & trigger latent disconnects.
  (This is done manually because Emacs seems to have dodgy support for TCP
  keepalive.)
docstring_tokens: Ping the socket to ensure it ' s alive & trigger latent disconnects . ( This is done manually because Emacs seems to have dodgy support for TCP keepalive . )
code: def _ping():
      """Ping the socket to ensure it's alive & trigger latent disconnects.
  
      (This is done manually because Emacs seems to have dodgy support for TCP
      keepalive.)
  
      """
      with _socket_lock:
          if emacs_focussed() and _socket:
              try:
                  # TODO: Why pending lock here
                  with _pending_lock:
                      # TODO: What if the second half of a message gets dropped, will
                      #   this still work?
                      _socket.sendall("\0\1\0".encode())
              except:
                  # Seems like even with this, sometimes the receive thread D/C isn't
                  # triggered. Just force it.
                  _force_disconnect()
code_tokens: def _ping ( ) : with _socket_lock : if emacs_focussed ( ) and _socket : try : with _pending_lock : _socket . sendall ( "\0\1\0" . encode ( ) ) except : _force_disconnect ( )
short_docstring: Ping the socket to ensure it's alive & trigger latent disconnects.
short_docstring_tokens: Ping the socket to ensure it ' s alive & trigger latent disconnects .
comment: """Ping the socket to ensure it's alive & trigger latent disconnects.
  
      (This is done manually because Emacs seems to have dodgy support for TCP
      keepalive.)
  
      """$SEP$# TODO: Why pending lock here$SEP$# TODO: What if the second half of a message gets dropped, will$SEP$#   this still work?$SEP$# Seems like even with this, sometimes the receive thread D/C isn't$SEP$# triggered. Just force it.