How to use the huey.consumer_options.ConsumerConfig function in huey

To help you get started, we’ve selected a few huey examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tranquilit / WAPT / lib / site-packages / huey / bin / huey_consumer.py View on Github external
def consumer_main():
    parser_handler = OptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()

    if len(args) == 0:
        err('Error:   missing import path to `Huey` instance')
        err('Example: huey_consumer.py app.queue.huey_instance')
        sys.exit(1)

    config = ConsumerConfig(**options.__dict__)
    config.validate()

    huey_instance = load_huey(args[0])
    config.setup_logger()

    consumer = Consumer(huey_instance, **config.values)
    consumer.run()
github coleifer / huey / huey / bin / huey_consumer.py View on Github external
def consumer_main():
    parser_handler = OptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()

    if len(args) == 0:
        err('Error:   missing import path to `Huey` instance')
        err('Example: huey_consumer.py app.queue.huey_instance')
        sys.exit(1)

    options = {k: v for k, v in options.__dict__.items()
               if v is not None}
    config = ConsumerConfig(**options)
    config.validate()

    huey_instance = load_huey(args[0])

    # Set up logging for the "huey" namespace.
    logger = logging.getLogger('huey')
    config.setup_logger(logger)

    consumer = huey_instance.create_consumer(**config.values)
    consumer.run()
github harvest-project / harvest / Harvest / management / commands / run_scheduler.py View on Github external
try:
            if isinstance(settings.HUEY, dict):
                consumer_options.update(settings.HUEY.get('consumer', {}))
        except AttributeError:
            pass

        for key, value in options.items():
            if value is not None:
                consumer_options[key] = value

        consumer_options.setdefault('verbose',
                                    consumer_options.pop('huey_verbose', None))

        autodiscover_modules("tasks")

        config = ConsumerConfig(**consumer_options)
        config.validate()
        config.setup_logger()

        Consumer.scheduler_class = HarvestHueyScheduler
        consumer = Consumer(HUEY, **config.values)
        consumer.run()
github APGSGA / hueyx / hueyx / management / commands / run_hueyx.py View on Github external
def run_consumer(self, queue_name):

        multiple_scheduler_locking = self.consumer_options.pop('multiple_scheduler_locking', False)

        HUEY = settings_reader.configurations[queue_name].huey_instance

        config = ConsumerConfig(**self.consumer_options)
        config.validate()
        config.setup_logger()

        logger.info(f'Run huey on {queue_name}')
        consumer = HueyxConsumer(HUEY, multiple_scheduler_locking=multiple_scheduler_locking, **config.values)
        consumer.run()
github coleifer / huey / huey / contrib / djhuey / management / commands / run_huey.py View on Github external
except AttributeError:
            pass

        for key, value in options.items():
            if value is not None:
                consumer_options[key] = value

        consumer_options.setdefault('verbose',
                                    consumer_options.pop('huey_verbose', None))

        if not options.get('disable_autoload'):
            autodiscover_modules("tasks")

        logger = logging.getLogger('huey')

        config = ConsumerConfig(**consumer_options)
        config.validate()

        # Only configure the "huey" logger if it has no handlers. For example,
        # some users may configure the huey logger via the Django global
        # logging config. This prevents duplicating log messages:
        if not logger.handlers:
            config.setup_logger(logger)

        consumer = Consumer(HUEY, **config.values)
        consumer.run()
github coleifer / huey / huey / consumer_options.py View on Github external
def __new__(cls, **kwargs):
        config = dict(config_defaults)
        config.update(kwargs)
        args = [config[key] for key in config_keys]
        return super(ConsumerConfig, cls).__new__(cls, *args)
github coleifer / huey / huey / contrib / djhuey / configuration.py View on Github external
def consumer(self):
        if self._consumer is None:
            config = ConsumerConfig(**self.consumer_options)
            config.validate()
            config.setup_logger()
            self._consumer = Consumer(self.huey, **config.values)
        return self._consumer