mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Reset persistent connection only if it is active (#33238)
Fixes #33237 Add check to reset connection only is persistent socket file exist Fix review comments
This commit is contained in:
parent
3a2c1541ca
commit
ff938bfdd5
1 changed files with 7 additions and 3 deletions
|
@ -36,7 +36,7 @@ from ansible.inventory.host import Host
|
||||||
from ansible.module_utils.six.moves import queue as Queue
|
from ansible.module_utils.six.moves import queue as Queue
|
||||||
from ansible.module_utils.six import iteritems, itervalues, string_types
|
from ansible.module_utils.six import iteritems, itervalues, string_types
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
from ansible.module_utils.connection import Connection
|
from ansible.module_utils.connection import Connection, ConnectionError
|
||||||
from ansible.playbook.helpers import load_list_of_blocks
|
from ansible.playbook.helpers import load_list_of_blocks
|
||||||
from ansible.playbook.included_file import IncludedFile
|
from ansible.playbook.included_file import IncludedFile
|
||||||
from ansible.playbook.task_include import TaskInclude
|
from ansible.playbook.task_include import TaskInclude
|
||||||
|
@ -140,8 +140,12 @@ class StrategyBase:
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# close active persistent connections
|
# close active persistent connections
|
||||||
for sock in itervalues(self._active_connections):
|
for sock in itervalues(self._active_connections):
|
||||||
conn = Connection(sock)
|
try:
|
||||||
conn.reset()
|
conn = Connection(sock)
|
||||||
|
conn.reset()
|
||||||
|
except ConnectionError as e:
|
||||||
|
# most likely socket is already closed
|
||||||
|
display.debug("got an error while closing persistent connection: %s" % e)
|
||||||
self._final_q.put(_sentinel)
|
self._final_q.put(_sentinel)
|
||||||
self._results_thread.join()
|
self._results_thread.join()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue