File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
2
# -*- coding: utf-8 -*-
3
+ from datetime import datetime
4
+
3
5
from backend .app .schemas .base import SchemaBase
4
6
5
7
@@ -12,4 +14,4 @@ class GetTask(SchemaBase):
12
14
misfire_grace_time : str
13
15
coalesce : str
14
16
max_instances : str
15
- next_run_time : str
17
+ next_run_time : datetime | None
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
2
# -*- coding: utf-8 -*-
3
+ from datetime import datetime
4
+
5
+ import pytz
3
6
from asgiref .sync import sync_to_async
4
7
5
8
from backend .app .common .exception import errors
6
9
from backend .app .common .task import scheduler
10
+ from backend .app .core .conf import settings
7
11
from backend .app .schemas .task import GetTask
8
- from backend .app .utils .timezone import timezone
9
12
10
13
11
14
class TaskService :
@@ -55,7 +58,8 @@ def get_task(pk: str):
55
58
56
59
async def run (self , pk : str ):
57
60
task = await self .get_task (pk = pk )
58
- scheduler .modify_job (job_id = pk , next_run_time = timezone .now ())
61
+ # next_run_time 仅适用于 pytz 模块
62
+ scheduler .modify_job (job_id = pk , next_run_time = datetime .now (pytz .timezone (settings .DATETIME_TIMEZONE )))
59
63
return task
60
64
61
65
async def pause (self , pk : str ):
You can’t perform that action at this time.
0 commit comments