-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding:utf-8 -*- | ||
from django_q.tasks import schedule | ||
from django_q.models import Schedule | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('default') | ||
|
||
|
||
def add_sql_schedule(name, run_date, workflow_id): | ||
"""添加/修改sql定时任务""" | ||
del_schedule(name) | ||
schedule('sql.utils.execute_sql.execute', workflow_id, | ||
hook='sql.utils.execute_sql.execute_callback', | ||
name=name, schedule_type='O', next_run=run_date, repeats=1) | ||
logger.debug(f"添加SQL定时执行任务:{name} 执行时间:{run_date}") | ||
|
||
|
||
def del_schedule(name): | ||
"""删除task""" | ||
try: | ||
sql_schedule = Schedule.objects.get(name=name) | ||
Schedule.delete(sql_schedule) | ||
logger.debug(f'删除task:{name}') | ||
except Schedule.DoesNotExist: | ||
logger.debug(f'删除task:{name}失败,任务不存在') | ||
|
||
|
||
def task_info(name): | ||
"""获取定时任务详情""" | ||
try: | ||
sql_schedule = Schedule.objects.get(name=name) | ||
return sql_schedule | ||
except Schedule.DoesNotExist: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters