Не работает переопределение on_decode_error для Consumer

Доброй ночи всем. Вот кусок кода Python модуля: customworker.py

from celery import Celery, bootsteps
from kombu import Consumer, Exchange, Queue

QUEUE = Queue(
    name='custom_worker_test',
    exchange=Exchange('customexchange', type='direct'),
    routing_key='custom_routing_key'
)

rabbit_url = "amqp://%s:%s@%s:%s/" % (broker_user, broker_password, broker_address, broker_port)

class WorkerConsumerStep(bootsteps.ConsumerStep):
    def get_consumers(self, channel):
        return [Consumer(
            channel, 
            queues=[QUEUE],
            callbacks=[self.handle_message],
            on_decode_error=self.custom_on_decode_error,
            accept=['text/plain', 'json', 'yaml', 'pickle', 'msgpack', 'application/x-msgpack']
        )]

    def handle_message(self, body, message):
        print('test handle_message') 

    def custom_on_decode_error(self, message, exc):
        print('test custom_on_decode_error') 

app = Celery('customworker', broker=rabbit_url)
app.steps['consumer'].add(WorkerConsumerStep)

Запуск воркера делаю так: celery worker -A customworker -n customworker -c 1 -Q custom_worker_test --loglevel=DEBUG --logfile=C:\test\customworker.log

Пакеты: kombu==4.6.3, celery==4.3.0

Собственно в чем заключается проблема.. Для Consumer'a переопределил on_decode_error и надеялся что будет вызываться моя функция custom_on_decode_error, но нет, в итоге расследования заметил что когда происходит ошибка декодирования в бой идет функция on_decode_error из celery.worker.consumer.consumer.py Каким образом можно сделать чтобы вызывалась моя функция custom_on_decode_error, естественно не затрагивая пакет celery?

Ибо надо пофиксить ошибку: Can't decode message body: ContentDisallowed('Refusing to deserialize untrusted content of type text/plain (text/plain)') [type:'text/plain' encoding:None headers:{}]


Ответы (0 шт):