[Update] 更改命令执行超时提示

pull/3428/head
ibuler 2019-10-24 10:23:31 +08:00
parent d5cb0a2e59
commit 9bb7c1adc1
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@
import uuid import uuid
import json import json
from celery.exceptions import SoftTimeLimitExceeded
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext from django.utils.translation import ugettext
@ -64,6 +65,9 @@ class CommandExecution(models.Model):
try: try:
result = runner.execute(self.command, 'all') result = runner.execute(self.command, 'all')
self.result = result.results_command self.result = result.results_command
except SoftTimeLimitExceeded as e:
print("Run timeout than 60s")
self.result = {"error": str(e)}
except Exception as e: except Exception as e:
print("Error occur: {}".format(e)) print("Error occur: {}".format(e))
self.result = {"error": str(e)} self.result = {"error": str(e)}