-
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.
Merge pull request #125 from hhyo/max_execution_time
增加在线查询超时时间配置,超时连接主动关闭
- Loading branch information
Showing
8 changed files
with
123 additions
and
89 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 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
ddfa689
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close #100