Commit 2de5cc19 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Disable wait for fasta generation on compressed fasta, it's always too long

parent 0ed669d0
......@@ -198,12 +198,12 @@ class Functions:
if compress:
Functions.compress(fasta_file_o)
os.remove(lock_file)
if mailer is not None:
if mailer is not None and not os.path.exists(lock_file + ".pending"):
Functions.send_fasta_ready(mailer, job_name, sample_name, compress)
@staticmethod
def compress_and_send_mail(job_name, fasta_file, index_file, lock_file, compressed, mailer):
Functions.compress(fasta_file)
os.remove(lock_file)
index, sample_name = Functions.read_index(index_file)
Functions.send_fasta_ready(mailer, job_name, sample_name, compressed)
os.remove(lock_file)
......@@ -215,6 +215,8 @@ def build_fasta(id_res):
if is_sorted and not query_fasta.endswith(".sorted"):
# Do the sort
Path(lock_query).touch()
if not compressed: # If compressed, it will took a long time, so not wait
Path(lock_query + ".pending").touch()
thread = threading.Timer(1, Functions.sort_fasta, kwargs={
"job_name": id_res,
"fasta_file": query_fasta,
......@@ -224,7 +226,19 @@ def build_fasta(id_res):
"mailer": mailer
})
thread.start()
return jsonify({"success": True, "status": 0, "status_message": "Started"})
if not compressed:
i = 0
time.sleep(5)
while os.path.exists(lock_query) and i < 2:
i += 1
time.sleep(5)
if os.path.exists(lock_query):
os.remove(lock_query + ".pending")
return jsonify({"success": True, "status": 1, "status_message": "In progress"})
return jsonify({"success": True, "status": 2, "status_message": "Done",
"gzip": query_fasta.endswith(".gz") or query_fasta.endswith(".gz.sorted")})
else:
return jsonify({"success": True, "status": 1, "status_message": "In progress"})
elif is_sorted and os.path.exists(lock_query):
# Sort is already in progress
return jsonify({"success": True, "status": 1, "status_message": "In progress"})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment