Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
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()
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()
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()
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()
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)
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