mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 01:19:29 +00:00
handle get single not found
This commit is contained in:
@@ -173,8 +173,11 @@ class TaskRedis(RedisBase):
|
|||||||
|
|
||||||
def get_single(self, task_id):
|
def get_single(self, task_id):
|
||||||
"""return content of single task"""
|
"""return content of single task"""
|
||||||
result = self.conn.execute_command("GET", self.BASE + task_id).decode()
|
result = self.conn.execute_command("GET", self.BASE + task_id)
|
||||||
return json.loads(result)
|
if not result:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return json.loads(result.decode())
|
||||||
|
|
||||||
def set_key(self, task_id, message, expire=False):
|
def set_key(self, task_id, message, expire=False):
|
||||||
"""set value for lock, initial or update"""
|
"""set value for lock, initial or update"""
|
||||||
@@ -191,6 +194,10 @@ class TaskRedis(RedisBase):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
message = self.get_single(task_id)
|
message = self.get_single(task_id)
|
||||||
|
if not message:
|
||||||
|
print(f"{task_id} not found")
|
||||||
|
raise KeyError
|
||||||
|
|
||||||
message.update({"command": command})
|
message.update({"command": command})
|
||||||
self.set_key(task_id, message)
|
self.set_key(task_id, message)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user