From 9bb7c1adc1f6172c06f2bda40150d267b971519c Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 24 Oct 2019 10:23:31 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E6=9B=B4=E6=94=B9=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=B6=85=E6=97=B6=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/models/command.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/ops/models/command.py b/apps/ops/models/command.py index dfa1dbe4d..3df42d5bc 100644 --- a/apps/ops/models/command.py +++ b/apps/ops/models/command.py @@ -3,6 +3,7 @@ import uuid import json +from celery.exceptions import SoftTimeLimitExceeded from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext @@ -64,6 +65,9 @@ class CommandExecution(models.Model): try: result = runner.execute(self.command, 'all') self.result = result.results_command + except SoftTimeLimitExceeded as e: + print("Run timeout than 60s") + self.result = {"error": str(e)} except Exception as e: print("Error occur: {}".format(e)) self.result = {"error": str(e)}