docs: def serve(handler, sock_path, timeout=UNIX_SOCKET_TIMEOUT):
      """
      Start the ssh-agent server on a UNIX-domain socket.
  
      If no connection is made during the specified timeout,
      retry until the context is over.
      """
      ssh_version = subprocess.check_output(['ssh', '-V'],
                                            stderr=subprocess.STDOUT)
      log.debug('local SSH version: %r', ssh_version)
      environ = {'SSH_AUTH_SOCK': sock_path, 'SSH_AGENT_PID': str(os.getpid())}
      device_mutex = threading.Lock()
      with server.unix_domain_socket_server(sock_path) as sock:
          sock.settimeout(timeout)
          quit_event = threading.Event()
          handle_conn = functools.partial(server.handle_connection,
                                          handler=handler,
                                          mutex=device_mutex)
          kwargs = dict(sock=sock,
                        handle_conn=handle_conn,
                        quit_event=quit_event)
          with server.spawn(server.server_thread, kwargs):
              try:
                  yield environ
              finally:
                  log.debug('closing server')
                  quit_event.set()