Fix global declaration placement in streaming task
This commit is contained in:
@@ -240,6 +240,7 @@ def run_stream(
|
|||||||
Returns:
|
Returns:
|
||||||
Dict with output_cid, output_path, and status
|
Dict with output_cid, output_path, and status
|
||||||
"""
|
"""
|
||||||
|
global _resolve_loop, _db_initialized
|
||||||
task_id = self.request.id
|
task_id = self.request.id
|
||||||
logger.info(f"Starting stream task {task_id} for run {run_id}")
|
logger.info(f"Starting stream task {task_id} for run {run_id}")
|
||||||
|
|
||||||
@@ -330,7 +331,6 @@ def run_stream(
|
|||||||
logger.info(f"Stream output cached: CID={cached_file.cid}, IPFS={ipfs_cid}")
|
logger.info(f"Stream output cached: CID={cached_file.cid}, IPFS={ipfs_cid}")
|
||||||
|
|
||||||
# Save to database - reuse the module-level loop to avoid pool conflicts
|
# Save to database - reuse the module-level loop to avoid pool conflicts
|
||||||
global _resolve_loop, _db_initialized
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import database
|
import database
|
||||||
|
|
||||||
@@ -379,7 +379,6 @@ def run_stream(
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
# Update pending run status to failed - reuse module loop
|
# Update pending run status to failed - reuse module loop
|
||||||
global _resolve_loop, _db_initialized
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import database
|
import database
|
||||||
|
|
||||||
@@ -412,7 +411,6 @@ def run_stream(
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
# Update pending run status to failed - reuse module loop
|
# Update pending run status to failed - reuse module loop
|
||||||
global _resolve_loop, _db_initialized
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import database
|
import database
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user