aboutsummaryrefslogtreecommitdiff
path: root/qc_app/jobs.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/jobs.py')
-rw-r--r--qc_app/jobs.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/qc_app/jobs.py b/qc_app/jobs.py
new file mode 100644
index 0000000..dbeb9ce
--- /dev/null
+++ b/qc_app/jobs.py
@@ -0,0 +1,19 @@
+from rq import Queue
+from redis import Redis
+from flask import current_app as app
+
+def enqueue_job(delayed_fn, *args, **kwargs):
+ with Redis.from_url(app.config["REDIS_URL"]) as rconn:
+ queue = Queue("qcapp_queue", connection=rconn)
+ job = queue.enqueue(delayed_fn, *args, **kwargs)
+
+ job.meta["status"] = "enqueued"
+ job.save_meta()
+ return job
+
+def job(job_id):
+ with Redis.from_url(app.config["REDIS_URL"]) as rconn:
+ queue = Queue("qcapp_queue", connection=rconn)
+ job = queue.fetch_job(job_id)
+
+ return job