perf: safe db connection on runner success

pull/15720/head
ibuler 2025-07-10 17:09:17 +08:00 committed by Bryan
parent 9e857b54ed
commit dfa0198742
1 changed files with 3 additions and 1 deletions

View File

@ -11,6 +11,7 @@ from django.utils.translation import gettext as _
from sshtunnel import SSHTunnelForwarder
from assets.automations.methods import platform_automation_methods
from common.db.utils import safe_db_connection
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
from ops.ansible import JMSInventory, DefaultCallback, SuperPlaybookRunner
from ops.ansible.interface import interface
@ -339,6 +340,7 @@ class BasePlaybookManager:
try:
kwargs.update({"clean_workspace": False})
cb = runner.run(**kwargs)
with safe_db_connection():
self.on_runner_success(runner, cb)
except Exception as e:
self.on_runner_failed(runner, e)