release notes

1.1.2

  • Doc updates

1.0.0

Monitor material theme

Added a material theme to the django-carrot monitor:

_images/monitor.png

material theme django-carrot monitor

Failure hooks

Implemented failure hooks, which run when a task fails. This can be used to re-queue a failed task a certain number of times before raising an exception. For example:

my_project/my_app/consumer.py

from carrot.utilities import publish_message

def failure_callback(log, exception):
    if log.task == 'myapp.tasks.retry_test':
        logger.critical(log.__dict__)
        attempt = log.positionals[0] + 1
        if attempt <= 5:
            log.delete()
            publish_message('myapp.tasks.retry_test', attempt)


class CustomConsumer(Consumer):
    def __init__(self, host, queue, logger, name, durable=True, queue_arguments=None, exchange_arguments=None):
        super(CustomConsumer, self).__init__(host, queue, logger, name, durable, queue_arguments, exchange_arguments)
        self.add_failure_callback(failure_callback)

my_project/my_app/tasks.py

def retry_test(attempt):
    logger.info('ATTEMPT NUMBER: %i' % attempt)
    do_stuff() # this method fails, because it isn't actually defined in this example

my_project/my_project/settings.py

CARROT = {
    'default_broker': vhost,
    'queues': [
        {
            'name': 'default',
            'host': vhost,
            'consumer_class': 'my_project.consumer.CustomConsumer',
        }
    ]
}