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
pull/32819/head
Ganesh Nalawade 7 years ago committed by GitHub
parent 3a2c1541ca
commit ff938bfdd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save