async def run_persistent(server_start_options_reader: PyreServerStartOptionsReader, remote_logging: Optional[backend_arguments.RemoteLogging]) -> int:
    (stdin, stdout) = (await connection.create_async_stdin_stdout())
    while True:
        initialize_result = (await try_initialize(stdin, stdout, server_start_options_reader))
        if isinstance(initialize_result, InitializationExit):
            LOG.info('Received exit request before initialization.')
            return 0
        elif isinstance(initialize_result, InitializationSuccess):
            LOG.info('Initialization successful.')
            client_info = initialize_result.client_info
            _log_lsp_event(remote_logging=remote_logging, event=LSPEvent.INITIALIZED, normals=({} if (client_info is None) else {'lsp client name': client_info.name, 'lsp client version': client_info.version}))
            client_capabilities = initialize_result.client_capabilities
            LOG.debug(f'Client capabilities: {client_capabilities}')
            initial_server_state = ServerState(client_capabilities=client_capabilities)
            pyre_query_handler = PyreQueryHandler(state=initial_server_state.query_state, server_start_options_reader=server_start_options_reader, client_output_channel=stdout)
            server = PyreServer(input_channel=stdin, output_channel=stdout, state=initial_server_state, pyre_manager=connection.BackgroundTaskManager(PyreServerHandler(server_start_options_reader=server_start_options_reader, remote_logging=remote_logging, client_output_channel=stdout, server_state=initial_server_state)), pyre_query_manager=connection.BackgroundTaskManager(pyre_query_handler))
            return (await server.run())
        elif isinstance(initialize_result, InitializationFailure):
            exception = initialize_result.exception
            message = (str(exception) if (exception is not None) else 'ignoring notification')
            LOG.info(f'Initialization failed: {message}')
            _log_lsp_event(remote_logging=remote_logging, event=LSPEvent.NOT_INITIALIZED, normals={'exception': message})
        else:
            raise RuntimeError('Cannot determine the type of initialize_result')
async def run_persistent(server_start_options_reader: PyreServerStartOptionsReader, remote_logging: Optional[backend_arguments.RemoteLogging]) -> int:
    (stdin, stdout) = (await connection.create_async_stdin_stdout())
    while True:
        initialize_result = (await try_initialize(stdin, stdout, server_start_options_reader))
        if isinstance(initialize_result, InitializationExit):
            LOG.info('Received exit request before initialization.')
            return 0
        elif isinstance(initialize_result, InitializationSuccess):
            LOG.info('Initialization successful.')
            client_info = initialize_result.client_info
            _log_lsp_event(remote_logging=remote_logging, event=LSPEvent.INITIALIZED, normals=({} if (client_info is None) else {'lsp client name': client_info.name, 'lsp client version': client_info.version}))
            client_capabilities = initialize_result.client_capabilities
            LOG.debug(f'Client capabilities: {client_capabilities}')
            initial_server_state = ServerState(client_capabilities=client_capabilities)
            pyre_query_handler = PyreQueryHandler(state=initial_server_state.query_state, server_start_options_reader=server_start_options_reader, client_output_channel=stdout)
            server = PyreServer(input_channel=stdin, output_channel=stdout, state=initial_server_state, pyre_manager=connection.BackgroundTaskManager(PyreServerHandler(server_start_options_reader=server_start_options_reader, remote_logging=remote_logging, client_output_channel=stdout, server_state=initial_server_state)), pyre_query_manager=connection.BackgroundTaskManager(pyre_query_handler))
            return (await server.run())
        elif isinstance(initialize_result, InitializationFailure):
            exception = initialize_result.exception
            message = (str(exception) if (exception is not None) else 'ignoring notification')
            LOG.info(f'Initialization failed: {message}')
            _log_lsp_event(remote_logging=remote_logging, event=LSPEvent.NOT_INITIALIZED, normals={'exception': message})
        else:
            raise RuntimeError('Cannot determine the type of initialize_result')