How to use the huey.consumer.Consumer 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
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 / contrib / djhuey / management / commands / run_huey.py View on Github external
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 harvest-project / harvest / Harvest / management / commands / run_scheduler.py View on Github external
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 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
github APGSGA / hueyx / hueyx / consumer.py View on Github external
return last_time_pattern != current_time_pattern

    def _get_last_execution_time_pattern(self, full_name: str):
        conn = self.huey.storage.conn
        current_val = conn.get(full_name)
        if current_val is not None:
            current_val = current_val.decode("utf-8")
        return current_val

    def _set_execution_time_pattern(self, full_name: str, now):
        current_time_pattern = self._create_time_pattern(now)
        conn: redis.Redis = self.huey.storage.conn
        conn.set(full_name, current_time_pattern)


class HueyxConsumer(Consumer):
    def __init__(self, *args, **kwargs):
        self.multiple_scheduler_locking = kwargs.pop('multiple_scheduler_locking', False)
        super().__init__(*args, **kwargs)

    def _create_scheduler(self):
        self._logger.info('multiple_scheduler_locking: ' + str(self.multiple_scheduler_locking))
        return HueyxScheduler(
            huey=self.huey,
            interval=self.scheduler_interval,
            periodic=self.periodic,
            multiple_scheduler_locking=self.multiple_scheduler_locking)

    def run(self):
        self.huey.heartbeat_manager.restart_dead_tasks()
        super().run()
github coleifer / huey / huey / api.py View on Github external
def create_consumer(self, **config):
        return Consumer(self, **config)
github harvest-project / harvest / Harvest / management / commands / run_scheduler.py View on Github external
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 coleifer / huey / huey / djhuey / management / commands / run_huey.py View on Github external
if options['periodic'] is not None:
            consumer_options['periodic'] = options['periodic']

        if options['initial_delay'] is not None:
            consumer_options['initial_delay'] = options['initial_delay']

        if options['max_delay'] is not None:
            consumer_options['max_delay'] = options['max_delay']

        self.autodiscover()

        loglevel = get_loglevel(consumer_options.pop('loglevel', None))
        logfile = consumer_options.pop('logfile', None)
        setup_logger(loglevel, logfile)

        consumer = Consumer(HUEY, **consumer_options)
        consumer.run()