F 修复任务调度可能丢失数据库连接的问题

pull/22/head
vapao 2020-01-22 14:00:26 +08:00
parent 4e5fe4046f
commit a7cef08176
1 changed files with 2 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from threading import Thread
from libs.ssh import SSH from libs.ssh import SSH
from apps.host.models import Host from apps.host.models import Host
from apps.setting.utils import AppSetting from apps.setting.utils import AppSetting
from django.db import close_old_connections
import subprocess import subprocess
import time import time
@ -30,6 +31,7 @@ def host_executor(q, host, pkey, command):
def dispatch(command, targets): def dispatch(command, targets):
close_old_connections()
threads, pkey, q = [], AppSetting.get('private_key'), Queue() threads, pkey, q = [], AppSetting.get('private_key'), Queue()
for t in targets: for t in targets:
if t == 'local': if t == 'local':