Sets the final status of a task in Redis.
(
task_id: str, status: str, message: str, details: Optional[Dict] = None
)
| 73 | |
| 74 | # --- Helper Function for Setting Final Status in Redis --- |
| 75 | def set_final_status( |
| 76 | task_id: str, status: str, message: str, details: Optional[Dict] = None |
| 77 | ): |
| 78 | """Sets the final status of a task in Redis.""" |
| 79 | redis_key = f"status_for_task:{task_id}" |
| 80 | status_data = { |
| 81 | "status": status, |
| 82 | "message": message, |
| 83 | "details": details or {}, |
| 84 | "timestamp": time.time(), # Add timestamp for potential debugging |
| 85 | } |
| 86 | try: |
| 87 | redis_client.set(redis_key, json.dumps(status_data), ex=FINAL_STATUS_TIMEOUT) |
| 88 | print( |
| 89 | f"Task {task_id}: Set final status in Redis ({redis_key}) to {status}. Message: {message}" |
| 90 | ) |
| 91 | except Exception as e: |
| 92 | print( |
| 93 | f"Task {task_id}: Failed to set final status '{status}' in Redis ({redis_key}): {e}", |
| 94 | exc_info=True, |
| 95 | ) |
| 96 | |
| 97 | |
| 98 | @huey.task(context=True) |
no outgoing calls
no test coverage detected