From 9170e293e896d1d283d3b19d79d673c9a92724d2 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 10 Mar 2021 14:26:01 +0300 Subject: Fix encoding issues with worker --- sheepdog/worker.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sheepdog/worker.py b/sheepdog/worker.py index 55dccc2..6299ca7 100644 --- a/sheepdog/worker.py +++ b/sheepdog/worker.py @@ -5,22 +5,19 @@ import time import redis import redis.connection - # Enable importing from one dir up since gn3 isn't installed as a globally -sys.path.append( - os.path.abspath(os.path.join(os.path.dirname(__file__), - '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) def run_jobs(conn): """Process the redis using a redis connection, CONN""" # pylint: disable=E0401, C0415 from gn3.commands import run_cmd - cmd_id = str(conn.lpop("GN3::job-queue")) + cmd_id = (conn.lpop("GN3::job-queue") or b'').decode("utf-8") if bool(cmd_id): cmd = conn.hget(name=cmd_id, key="cmd") - if cmd and (str(conn.hget(cmd, "status")) == "queued"): - result = run_cmd(cmd) + if cmd and (conn.hget(cmd, "status") == b"queued"): + result = run_cmd(cmd.decode("utf-8")) conn.hset(name=cmd_id, key="result", value=result.get("output")) if result.get("code") == 0: # Success conn.hset(name=cmd_id, key="status", value="success") -- cgit v1.2.3