docs: def backdoor_handler(clientsock, namespace=None):
      """start an interactive python interpreter on an existing connection
  
      .. note::
          this function will block for as long as the connection remains alive.
  
      :param sock: the socket on which to serve the interpreter
      :type sock: :class:`Socket<greenhouse.io.sockets.Socket>`
      :param namespace:
          the local namespace dict for the interpreter, or None to have the
          function create its own empty namespace
      :type namespace: dict or None
      """
      namespace = {} if namespace is None else namespace.copy()
      console = code.InteractiveConsole(namespace)
      multiline_statement = []
      stdout, stderr = StringIO(), StringIO()
  
      clientsock.sendall(PREAMBLE + "\n" + PS1)
  
      for input_line in _produce_lines(clientsock):
          input_line = input_line.rstrip()
          if input_line:
              input_line = '\n' + input_line
          source = '\n'.join(multiline_statement) + input_line
          response = ''
  
          with _wrap_stdio(stdout, stderr):
              result = console.runsource(source)
  
          response += stdout.getvalue()
          err = stderr.getvalue()
          if err:
              response += err
  
          if err or not result:
              multiline_statement = []
              response += PS1
          else:
              multiline_statement.append(input_line)
              response += PS2
  
          clientsock.sendall(response)