def callback(status, message, job, result, exception, stacktrace):
    """Example callback function.

    :param status: Job status. Possible values are "invalid" (job could not be
        deserialized or was malformed), "failure" (job raised an exception),
        "timeout" (job timed out), or "success" (job finished successfully and
        returned a result).
    :type status: str
    :param message: Kafka message.
    :type message: kq.Message
    :param job: Job object, or None if **status** was "invalid".
    :type job: kq.Job
    :param result: Job result, or None if an exception was raised.
    :type result: object | None
    :param exception: Exception raised by job, or None if there was none.
    :type exception: Exception | None
    :param stacktrace: Exception traceback, or None if there was none.
    :type stacktrace: str | None
    """
    assert status in ['invalid', 'success', 'timeout', 'failure']
    assert isinstance(message, Message)

    if status == 'invalid':
        assert job is None
        assert result is None
        assert exception is None
        assert stacktrace is None

    if status == 'success':
        assert isinstance(job, Job)
        assert exception is None
        assert stacktrace is None

    elif status == 'timeout':
        assert isinstance(job, Job)
        assert result is None
        assert exception is None
        assert stacktrace is None

    elif status == 'failure':
        assert isinstance(job, Job)
        assert result is None
        assert exception is not None
        assert stacktrace is not None
Example callback function.

    :param status: Job status. Possible values are "invalid" (job could not be
        deserialized or was malformed), "failure" (job raised an exception),
        "timeout" (job timed out), or "success" (job finished successfully and
        returned a result).
    :type status: str
    :param message: Kafka message.
    :type message: kq.Message
    :param job: Job object, or None if **status** was "invalid".
    :type job: kq.Job
    :param result: Job result, or None if an exception was raised.
    :type result: object | None
    :param exception: Exception raised by job, or None if there was none.
    :type exception: Exception | None
    :param stacktrace: Exception traceback, or None if there was none.
    :type stacktrace: str | None