|
@@ -15,9 +15,11 @@ from applications.tasks.monitor_tasks import CheckVideoAuditStatus
|
|
|
from applications.tasks.monitor_tasks import InnerGzhArticlesMonitor
|
|
|
from applications.tasks.monitor_tasks import OutsideGzhArticlesMonitor
|
|
|
from applications.tasks.monitor_tasks import OutsideGzhArticlesCollector
|
|
|
+from applications.tasks.monitor_tasks import TaskProcessingMonitor
|
|
|
+from applications.tasks.task_mapper import TaskMapper
|
|
|
|
|
|
|
|
|
-class TaskScheduler:
|
|
|
+class TaskScheduler(TaskMapper):
|
|
|
def __init__(self, data, log_service, db_client):
|
|
|
self.data = data
|
|
|
self.log_client = log_service
|
|
@@ -37,10 +39,12 @@ class TaskScheduler:
|
|
|
return False
|
|
|
else:
|
|
|
start_timestamp = response[0]["start_timestamp"]
|
|
|
- # todo: every task should has a unique expire timestamp, remember to write that in a task config file
|
|
|
- if int(time.time()) - start_timestamp >= 86400:
|
|
|
+
|
|
|
+ if int(time.time()) - start_timestamp >= self.get_task_config(
|
|
|
+ task_name
|
|
|
+ ).get("expire_duration", self.DEFAULT_TIMEOUT):
|
|
|
await feishu_robot.bot(
|
|
|
- title=f"{task_name} has been processing for more than one day",
|
|
|
+ title=f"{task_name} has been processing over timeout",
|
|
|
detail={"timestamp": start_timestamp},
|
|
|
env="long_articles_task",
|
|
|
)
|
|
@@ -257,6 +261,18 @@ class TaskScheduler:
|
|
|
data={"code": 0, "message": "task started background"},
|
|
|
)
|
|
|
|
|
|
+ case "task_processing_monitor":
|
|
|
+ async def background_task_processing_monitor():
|
|
|
+ sub_task = TaskProcessingMonitor(self.db_client)
|
|
|
+ await sub_task.deal()
|
|
|
+ await self.release_task(task_name=task_name, date_string=date_string, final_status=2)
|
|
|
+
|
|
|
+ asyncio.create_task(background_task_processing_monitor())
|
|
|
+ return await task_schedule_response.success_response(
|
|
|
+ task_name=task_name,
|
|
|
+ data={"code": 0, "message": "task started background"},
|
|
|
+ )
|
|
|
+
|
|
|
case _:
|
|
|
await self.log_client.log(
|
|
|
contents={
|