mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
[enh] handle running job cancelation
This commit is contained in:
parent
23a12d61c0
commit
34873ae9f8
1 changed files with 8 additions and 0 deletions
8
run.py
8
run.py
|
@ -12,6 +12,7 @@ import itertools
|
|||
from datetime import datetime, date
|
||||
from collections import defaultdict
|
||||
from functools import wraps
|
||||
from concurrent.futures._base import CancelledError
|
||||
|
||||
import ujson
|
||||
import aiohttp
|
||||
|
@ -354,6 +355,13 @@ async def run_job(worker, job):
|
|||
"data": model_to_dict(job),
|
||||
}, ["jobs", f"job-{job.id}", f"app-jobs-{job.url_or_path}"])
|
||||
|
||||
except CancelledError:
|
||||
job.log += "\n"
|
||||
job.end_time = datetime.now()
|
||||
job.state = "canceled"
|
||||
job.save()
|
||||
|
||||
task_logger.info(f"Job '{job.name} #{job.id}' has been canceled")
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
task_logger.exception(f"ERROR in job '{job.name} #{job.id}'")
|
||||
|
|
Loading…
Add table
Reference in a new issue