aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-06-02 12:57:18 +0300
committerFrederick Muriuki Muriithi2022-06-02 12:57:18 +0300
commit2f84b2eb1fecab4c381ad2dfd31277717cc9df2d (patch)
treec8a9080401ba40869454f55c88cd359bdbc393dd /scripts
parent219248568252e7291f20105ce589c87c5a85f433 (diff)
downloadgn-uploader-2f84b2eb1fecab4c381ad2dfd31277717cc9df2d.tar.gz
Enable user abortion of file parsing
Enable the user to abort the background parsing of the file.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/worker.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/scripts/worker.py b/scripts/worker.py
index 6fab9f9..0ef5ae5 100644
--- a/scripts/worker.py
+++ b/scripts/worker.py
@@ -54,6 +54,16 @@ def stream_error(redis_conn, job_id, error):
redis_conn.hset(
job_id, key="errors", value=jsonpickle.encode(errors + (error,)))
+def make_user_aborted(redis_conn, job_id):
+ def __aborted__():
+ user_aborted = bool(int(
+ redis_conn.hget(name=job_id, key="user_aborted") or "0"))
+ if user_aborted:
+ redis_conn.hset(name=job_id, key="status", value="aborted")
+
+ return user_aborted
+ return __aborted__
+
def main():
args = process_cli_arguments()
if args is None:
@@ -79,7 +89,8 @@ def main():
error_count = 0
for error in collect_errors(
- filepath, filetype, strains, progress_indicator):
+ filepath, filetype, strains, progress_indicator,
+ make_user_aborted(redis_conn, args.job_id)):
stream_error(redis_conn, args.job_id, error)
if count > 0: