Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
backend = config['queue']['backend']
except:
print configuration_message
sys.exit(1)
_db = settings.DATABASES
if 'default' in _db and _db['default'].get('NAME'):
backup_name = _db['default']['NAME'].rsplit('/', 1)[-1]
else:
backup_name = 'huey'
queue = config.pop('queue')
if isinstance(queue, dict):
QueueClass = load_class(queue['backend'])
queue = QueueClass(
queue.get('name', backup_name),
**queue.get('connection', {})
)
result_store = config.pop('result_store', None)
if isinstance(result_store, dict):
DataStoreClass = load_class(result_store['backend'])
result_store = DataStoreClass(
result_store.get('name', backup_name),
**result_store.get('connection', {})
)
always_eager = config.pop('always_eager', False)
huey = Huey(queue, result_store, always_eager=always_eager)
options, args = parser.parse_args()
if options.verbose is None:
loglevel = logging.INFO
elif options.verbose:
loglevel = logging.DEBUG
else:
loglevel = logging.ERROR
if len(args) == 0:
err('Error: missing import path to `Huey` instance')
err('Example: huey_consumer.py app.queue.huey_instance')
sys.exit(1)
try:
huey_instance = load_class(args[0])
except:
err('Error importing %s' % args[0])
sys.exit(2)
consumer = Consumer(
huey_instance,
options.logfile,
loglevel,
options.threads,
options.periodic,
options.initial_delay,
options.backoff,
options.max_delay,
options.utc)
consumer.run()
backup_name = _db['default']['NAME'].rsplit('/', 1)[-1]
else:
backup_name = 'huey'
queue = config.pop('queue')
if isinstance(queue, dict):
QueueClass = load_class(queue['backend'])
queue = QueueClass(
queue.get('name', backup_name),
**queue.get('connection', {})
)
result_store = config.pop('result_store', None)
if isinstance(result_store, dict):
DataStoreClass = load_class(result_store['backend'])
result_store = DataStoreClass(
result_store.get('name', backup_name),
**result_store.get('connection', {})
)
always_eager = config.pop('always_eager', False)
huey = Huey(queue, result_store, always_eager=always_eager)
def load_huey(path):
try:
return load_class(path)
except:
cur_dir = os.getcwd()
if cur_dir not in sys.path:
sys.path.insert(0, cur_dir)
return load_huey(path)
err('Error importing %s' % path)
raise
def load_huey(path):
try:
return load_class(path)
except:
cur_dir = os.getcwd()
if cur_dir not in sys.path:
sys.path.insert(0, cur_dir)
return load_huey(path)
err('Error importing %s' % path)
raise
def dynamic_import(obj, key, required=False):
try:
path = obj[key]
except KeyError:
if required:
config_error('Missing required configuration: "%s"' % key)
return None
try:
return load_class(path + '.Components')
except ImportError:
config_error('Unable to import %s: "%s"' % (key, path))