aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/jobs.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/qc_app/jobs.py b/qc_app/jobs.py
index 9b350b7..dc9ba92 100644
--- a/qc_app/jobs.py
+++ b/qc_app/jobs.py
@@ -1,11 +1,13 @@
"""Handle jobs"""
import os
+import sys
import shlex
import subprocess
from uuid import uuid4
from datetime import timedelta
from redis import Redis
+from flask import current_app as app
def error_filename(job_id, error_dir):
"Compute the path of the file where errors will be dumped."
@@ -29,7 +31,7 @@ def build_file_verification_job(
"Build a file verification job"
job_id = str(uuid4())
command = [
- "python3", "-m", "scripts.validate_file", filetype, filepath, redisurl,
+ sys.executable, "-m", "scripts.validate_file", filetype, filepath, redisurl,
job_id
]
return __init_job__(
@@ -44,8 +46,8 @@ def data_insertion_job(# pylint: disable=[too-many-arguments]
ttl_seconds: int) -> dict:
"Build a data insertion job"
command = [
- "python3", "-m", "scripts.insert_data", filetype, filepath, speciesid,
- platformid, datasetid, databaseuri, redisuri
+ sys.executable, "-m", "scripts.insert_data", filetype, filepath,
+ speciesid, platformid, datasetid, databaseuri, redisuri
]
return __init_job__(
redis_conn, str(uuid4()), command, "data-insertion", ttl_seconds, {
@@ -62,8 +64,9 @@ def launch_job(the_job: dict, redisurl: str, error_dir):
"w",
encoding="utf-8") as errorfile:
subprocess.Popen( # pylint: disable=[consider-using-with]
- ["python3", "-m", "scripts.worker", redisurl, job_id],
- stderr=errorfile)
+ [sys.executable, "-m", "scripts.worker", redisurl, job_id],
+ stderr=errorfile,
+ env={"PYTHONPATH": ":".join(sys.path)})
return the_job