about summary refs log tree commit diff
path: root/gn3/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/commands.py')
-rw-r--r--gn3/commands.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/gn3/commands.py b/gn3/commands.py
index eba01b1..b4db447 100644
--- a/gn3/commands.py
+++ b/gn3/commands.py
@@ -18,7 +18,7 @@ from typing import Union
 from typing import Sequence
 from uuid import uuid4
 
-from flask import current_app
+from flask import Flask, current_app
 from redis.client import Redis  # Used only in type hinting
 
 from pymonad.either import Either, Left, Right
@@ -174,6 +174,16 @@ def run_cmd(cmd: str, success_codes: Tuple = (0,), env: Optional[str] = None) ->
             current_app.logger.debug if current_app else logging.debug)(out)
     return {"code": results.returncode, "output": out}
 
+
+def compute_job_queue(app: Flask) -> str:
+    """Use the app configurations to compute the job queue"""
+    app_env = app.config["APPLICATION_ENVIRONMENT"]
+    job_queue = app.config["REDIS_JOB_QUEUE"]
+    if bool(app_env):
+        return f"{app_env}::{job_queue}"
+    return job_queue
+
+
 def run_async_cmd(
         conn: Redis, job_queue: str, cmd: Union[str, Sequence[str]],
         email: Optional[str] = None, log_level: str = "info",