class_docstr: ChatServiceMessageSocket is a wrapper around websocket to forward messages from the
  remote server to the ChatServiceManager.
class_docstr_tok: ["ChatServiceMessageSocket","is","a","wrapper","around","websocket","to","forward","messages","from","the","remote","server","to","the","ChatServiceManager","."]
code: def _safe_send(self, data, force=False):
      if not self.alive and not force:
          # Try to wait a second to send a packet
          timeout = 1
          while timeout > 0 and not self.alive:
              time.sleep(0.1)
              timeout -= 0.1
          if not self.alive:
              # don't try to send a packet if we're still dead
              return False
      try:
          self.ws.send(data)
      except websocket.WebSocketConnectionClosedException:
          # The channel died mid-send, wait for it to come back up
          return False
      return True
  
file_path: ParlAI/parlai/chat_service/core/socket.py
imports: import errno
  import json
  import logging
  import threading
  import time
  import websocket
  import parlai.chat_service.utils.logging
label_desc: Use image node_id 2 for calling the ChatServiceMessageSocket obj's underlying member method code with example usage: obj._safe_send(data, force) and returns: True, False, False