Spaces:
Running
Running
fix: move first _set_step into try block + stderr fallback in run_pipeline_sync
Browse files
bioai-platform/backend/app/workers/pipeline_worker.py
CHANGED
|
@@ -75,9 +75,9 @@ async def execute_blast_job(job_id: str, sequence: str) -> None:
|
|
| 75 |
})
|
| 76 |
logger.info(f"[{job_id}] Step: {step}")
|
| 77 |
|
| 78 |
-
await _set_step("submitted_to_ncbi", 10)
|
| 79 |
-
|
| 80 |
try:
|
|
|
|
|
|
|
| 81 |
sequence_clean = "".join(c for c in sequence if c.isalpha()).upper()
|
| 82 |
seq_for_blast = sequence_clean if len(sequence_clean) > 20 else sequence_clean
|
| 83 |
|
|
@@ -223,10 +223,15 @@ async def execute_blast_job(job_id: str, sequence: str) -> None:
|
|
| 223 |
|
| 224 |
|
| 225 |
def run_pipeline_sync(job_id: str, sequence: str, database: str = "nr", max_hits: int = 10) -> None:
|
|
|
|
| 226 |
loop = asyncio.new_event_loop()
|
| 227 |
asyncio.set_event_loop(loop)
|
| 228 |
try:
|
| 229 |
loop.run_until_complete(execute_blast_job(job_id, sequence))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
finally:
|
| 231 |
loop.close()
|
| 232 |
asyncio.set_event_loop(None)
|
|
|
|
| 75 |
})
|
| 76 |
logger.info(f"[{job_id}] Step: {step}")
|
| 77 |
|
|
|
|
|
|
|
| 78 |
try:
|
| 79 |
+
await _set_step("submitted_to_ncbi", 10)
|
| 80 |
+
|
| 81 |
sequence_clean = "".join(c for c in sequence if c.isalpha()).upper()
|
| 82 |
seq_for_blast = sequence_clean if len(sequence_clean) > 20 else sequence_clean
|
| 83 |
|
|
|
|
| 223 |
|
| 224 |
|
| 225 |
def run_pipeline_sync(job_id: str, sequence: str, database: str = "nr", max_hits: int = 10) -> None:
|
| 226 |
+
import sys
|
| 227 |
loop = asyncio.new_event_loop()
|
| 228 |
asyncio.set_event_loop(loop)
|
| 229 |
try:
|
| 230 |
loop.run_until_complete(execute_blast_job(job_id, sequence))
|
| 231 |
+
except Exception:
|
| 232 |
+
sys.stderr.write(f"[{job_id}] FATAL: unhandled exception in background thread\n")
|
| 233 |
+
sys.stderr.flush()
|
| 234 |
+
raise
|
| 235 |
finally:
|
| 236 |
loop.close()
|
| 237 |
asyncio.set_event_loop(None)
|