added segments
This commit is contained in:
@@ -220,4 +220,24 @@ class JobManager:
|
||||
job.end_time = datetime.now()
|
||||
db.commit()
|
||||
|
||||
def force_fail_job(self, job_id: str):
|
||||
"""
|
||||
Forcefully mark a job as failed in the database.
|
||||
This does not guarantee the underlying thread stops immediately,
|
||||
but it releases the UI state.
|
||||
"""
|
||||
with self._get_db() as db:
|
||||
job = db.query(Job).filter(Job.id == job_id).first()
|
||||
if job:
|
||||
# We update status regardless of current state if user wants to force it
|
||||
prev_status = job.status
|
||||
job.status = "failed"
|
||||
job.message = f"Forcefully killed by user (was {prev_status})"
|
||||
job.end_time = datetime.now()
|
||||
job.cancel_requested = True # Hint to thread if it's still alive
|
||||
db.commit()
|
||||
logger.warning(f"Job {job_id} was forcefully killed by user.")
|
||||
return True
|
||||
return False
|
||||
|
||||
job_manager = JobManager()
|
||||
|
||||
Reference in New Issue
Block a user