def METHOD_NAME(session_ingest_consumer, task_runner):
    """
    Returns a function that can be used to create a wait loop for the ingest consumer
    The ingest consumer will be called in a loop followed by a query to the supplied
    predicate. If the predicate returns a non None value the wait will be ended and
    the waiter will return whatever the predicate returned.
    If the max_time passes the waiter will be terminated and the waiter will return None
    Note: The reason there we return a factory and not directly the waiter is that we
    need to configure the consumer with the test settings (settings are typically available
    in the test) so a test would typically first create the waiter and the use it to wait for
    the required condition:
    waiter = wait_for_ingest_consumer( test_settings_derived_from_the_project_settings)
    result = waiter( my_predicate, SOME_TIMEOUT)
    assert result == expected_result
    """
    def factory(settings, **kwargs):
        consumer = session_ingest_consumer(settings, **kwargs)
        def waiter(exit_predicate, max_time=MAX_SECONDS_WAITING_FOR_EVENT):
            """
            Implements a wait loop for the ingest consumer
            :param exit_predicate:  A Callable[(),Any] that will be called in a loop after each call
                to the KafkaConsumer _run_once()
            :param max_time: maximum time in seconds to wait
            :return: the first non None result returned by the exit predicate or None if the
                max time has expired without the exit predicate returning a non None value
            """
            start_wait = time.time()
            with task_runner():
                while time.time() - start_wait < max_time:
                    consumer._run_once()
                    # check if the condition is satisfied
                    val = exit_predicate()
                    if val is not None:
                        return val  # we got what we were waiting for stop looping
            _log.warning(
                "Ingest consumer waiter timed-out after %d seconds", time.time() - start_wait
            )
            return None  # timeout without any success
        return waiter
    return factory