code: def _listen(self):
          
  
          def _listen():
              """This runs in a thread"""
              for line in iter(sys.stdin.readline, b""):
                  try:
                      response = json.loads(line)
  
                  except Exception as e:
                      # The parent has passed on a message that
                      # isn't formatted in any particular way.
                      # This is likely a bug.
                      raise e
  
                  else:
                      if response.get("header") == "pyblish-qml:popen.response":
                          self.channels["response"].put(line)
  
                      elif response.get("header") == "pyblish-qml:popen.parent":
                          self.channels["parent"].put(line)
  
                      elif response.get("header") == "pyblish-qml:server.pulse":
                          self._kill.cancel()  # reset timer
                          self._self_destruct()
  
                      else:
                          # The parent has passed on a message that
                          # is JSON, but not in any format we recognise.
                          # This is likely a bug.
                          raise Exception("Unhandled message "
                                          "passed to Popen, '%s'" % line)
  
          thread = threading.Thread(target=_listen)
          thread.daemon = True
          thread.start()
docs: Listen for messages passed from parent
  
          This method distributes messages received via stdin to their
          corresponding channel. Based on the format of the incoming
          message, the message is forwarded to its corresponding channel
          to be processed by its corresponding handler.