From 53d81e0d9f66f09b63e5b36bd33c79e8bc930215 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 16 Feb 2021 20:25:54 +0300 Subject: Add extra option to set email when queueing CMD The e-mail field will be used to send the results of the computation when it is completed. --- gn3/commands.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gn3') diff --git a/gn3/commands.py b/gn3/commands.py index e5a3b1e..7201a68 100644 --- a/gn3/commands.py +++ b/gn3/commands.py @@ -48,10 +48,10 @@ def compose_gemma_cmd( return cmd -def queue_cmd(cmd: str, conn: Redis) -> str: - """Given a command CMD, and a redis connection CONN, queue it in Redis -with an initial status of 'queued'. The following status codes are -supported: +def queue_cmd(conn: Redis, cmd: str, email: Optional[str] = None) -> str: + """Given a command CMD; (optional) EMAIL; and a redis connection CONN, queue +it in Redis with an initial status of 'queued'. The following status codes +are supported: queued: Unprocessed; Still in the queue running: Still running @@ -70,6 +70,10 @@ supported: conn.hset(key, value, unique_id) conn.rpush("GN2::job-queue", unique_id) + if email: + conn.hset("email", + email, + unique_id) return unique_id -- cgit v1.2.3