Coverage for portality/tasks/redis_huey.py: 88%
16 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-11-09 15:10 +0000
« prev ^ index » next coverage.py v6.4.2, created at 2022-11-09 15:10 +0000
1from huey import RedisHuey, crontab
2from portality.core import app
4main_queue = RedisHuey('doaj_main_queue', host=app.config['HUEY_REDIS_HOST'], port=app.config['HUEY_REDIS_PORT'], always_eager=app.config.get("HUEY_EAGER", False))
6long_running = RedisHuey('doaj_long_running', host=app.config['HUEY_REDIS_HOST'], port=app.config['HUEY_REDIS_PORT'], always_eager=app.config.get("HUEY_EAGER", False))
9def schedule(action):
10 cfg = app.config.get("HUEY_SCHEDULE", {})
11 action_cfg = cfg.get(action)
12 if action_cfg is None:
13 raise RuntimeError("No configuration for scheduled action '{x}'. Define this in HUEY_SCHEDULE first then try again.".format(x=action))
15 return crontab(**action_cfg)
18def configure(action):
19 cfg = app.config.get("HUEY_TASKS", {})
20 action_cfg = cfg.get(action)
21 if action_cfg is None:
22 raise RuntimeError("No task configuration for action '{x}'. Define this in HUEY_TASKS first then try again.".format(x=action))
23 return action_cfg