about summary refs log tree commit diff
path: root/sheepdog/worker.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-08 12:38:34 -0500
committerFrederick Muriuki Muriithi2025-04-08 13:46:01 -0500
commit76c3800320b722edcd24b73ed1a9b860f305ecb8 (patch)
tree085ffc370e360cdda1e4c1c48f3555a3bfd45897 /sheepdog/worker.py
parentfca547664fcbc96340c5646267cc40d419d4ae57 (diff)
downloadgenenetwork3-76c3800320b722edcd24b73ed1a9b860f305ecb8.tar.gz
sheepdog.worker: Pass in the queue name on the CLI
Pass in the name of the queue where the jobs are queued to the worker.
Diffstat (limited to 'sheepdog/worker.py')
-rw-r--r--sheepdog/worker.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/sheepdog/worker.py b/sheepdog/worker.py
index c08edec..b5b0f16 100644
--- a/sheepdog/worker.py
+++ b/sheepdog/worker.py
@@ -36,7 +36,7 @@ def make_incremental_backoff(init_val: float=0.1, maximum: int=420):
 
     return __increment_or_reset__
 
-def run_jobs(conn, queue_name: str = "GN3::job-queue"):
+def run_jobs(conn, queue_name):
     """Process the redis using a redis connection, CONN"""
     # pylint: disable=E0401, C0415
     from gn3.commands import run_cmd
@@ -65,17 +65,20 @@ def parse_cli_arguments():
         help=(
             "Run process as a daemon instead of the default 'one-shot' "
             "process"))
+    parser.add_argument(
+        "--queue-name", default="GN3::job-queue", type=str,
+        help="The redis list that holds the unique command ids")
     return parser.parse_args()
 
 if __name__ == "__main__":
     args = parse_cli_arguments()
     with redis.Redis() as redis_conn:
         if not args.daemon:
-            run_jobs(redis_conn)
+            run_jobs(redis_conn, args.queue_name)
         else:
             sleep_time = make_incremental_backoff()
             while True:  # Daemon that keeps running forever:
-                if run_jobs(redis_conn):
+                if run_jobs(redis_conn, args.queue_name):
                     time.sleep(sleep_time("reset"))
                     continue
                 time.sleep(sleep_time("increment", sleep_time("return_current")))