File tree 1 file changed +15
-0
lines changed
mobsf/StaticAnalyzer/views/common
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 4
4
timedelta ,
5
5
)
6
6
7
+ from django .dispatch import receiver
7
8
from django .utils import timezone
8
9
from django .shortcuts import render
9
10
from django .conf import settings
14
15
from django .views .decorators .http import require_http_methods
15
16
16
17
from django_q .tasks import async_task
18
+ from django_q .signals import post_execute
17
19
18
20
from mobsf .StaticAnalyzer .models import (
19
21
EnqueuedTask ,
30
32
logger = logging .getLogger (__name__ )
31
33
32
34
35
+ @receiver (post_execute )
36
+ def detect_timeout (sender , task , ** kwargs ):
37
+ """Detect scan task timeout."""
38
+ if 'Task exceeded maximum timeout' in task ['result' ]:
39
+ task_id = task ['id' ]
40
+ EnqueuedTask .objects .filter (task_id = task_id ).update (
41
+ app_name = 'Failed' ,
42
+ completed_at = timezone .now (),
43
+ status = 'Scan Timeout' ,
44
+ )
45
+ logger .error ('Task %s exceeded maximum timeout' , task_id )
46
+
47
+
33
48
def async_analysis (checksum , app_name , func , * args ):
34
49
"""Async Analysis Task."""
35
50
# Check if the task is already completed
You can’t perform that action at this time.
0 commit comments