def _submit_feedback_functions(
        record: record_schema.Record,
        feedback_functions: Sequence[core_feedback.Feedback],
        connector: db_connector.DBConnector,
        app: Optional[AppDefinition] = None,
        on_done: Optional[
            Callable[
                [
                    Union[
                        feedback_schema.FeedbackResult,
                        Future[feedback_schema.FeedbackResult],
                    ]
                ],
                None,
            ]
        ] = None,
    ) -> List[
        Tuple[core_feedback.Feedback, Future[feedback_schema.FeedbackResult]]
    ]:
        """Schedules to run the given feedback functions.

        Args:
            record: The record on which to evaluate the feedback functions.

            feedback_functions: A collection of feedback functions to evaluate.

            connector: The database connector to use.

            app: The app that produced the given record. If not provided, it is
                looked up from the database of this `TruSession` instance

            on_done: A callback to call when each feedback function is done.

        Returns:

            List[Tuple[Feedback, Future[FeedbackResult]]]

            Produces a list of tuples where the first item in each tuple is the
            feedback function and the second is the future of the feedback result.
        """

        app_id = record.app_id

        if app is None:
            app = AppDefinition.model_validate(connector.get_app(app_id=app_id))
            if app is None:
                raise RuntimeError(
                    f"App {app_id} not present in db. "
                    "Either add it with `TruSession.add_app` or provide `app_json` to `TruSession.run_feedback_functions`."
                )

        else:
            assert (
                app_id == app.app_id
            ), "Record was produced by a different app."

            if connector.get_app(app_id=app.app_id) is None:
                logger.warning(
                    f"App {app_id} was not present in database. Adding it."
                )
                connector.add_app(app=app)

        feedbacks_and_futures = []

        tp = threading_utils.TP()

        for ffunc in feedback_functions:
            # Run feedback function and the on_done callback. This makes sure
            # that Future.result() returns only after on_done has finished.
            def run_and_call_callback(
                ffunc: core_feedback.Feedback,
                app: AppDefinition,
                record: record_schema.Record,
            ):
                token = None
                try:
                    token = core_instruments.do_not_track.set(True)
                    temp = ffunc.run(app=app, record=record)
                    if on_done is not None:
                        try:
                            on_done(temp)
                        finally:
                            return temp
                    return temp
                finally:
                    if token is not None:
                        core_instruments.do_not_track.reset(token)

            fut: Future[feedback_schema.FeedbackResult] = tp.submit(
                run_and_call_callback,
                ffunc=ffunc,
                app=app,
                record=record,
            )

            # Have to roll the on_done callback into the submitted function
            # because the result() is returned before callback runs otherwise.
            # We want to do db work before result is returned.

            feedbacks_and_futures.append((ffunc, fut))

        return feedbacks_and_futures
Schedules to run the given feedback functions.

        Args:
            record: The record on which to evaluate the feedback functions.

            feedback_functions: A collection of feedback functions to evaluate.

            connector: The database connector to use.

            app: The app that produced the given record. If not provided, it is
                looked up from the database of this `TruSession` instance

            on_done: A callback to call when each feedback function is done.

        Returns:

            List[Tuple[Feedback, Future[FeedbackResult]]]

            Produces a list of tuples where the first item in each tuple is the
            feedback function and the second is the future of the feedback result.
        
src/core/trulens/core/schema/app.py