summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2021-06-14 23:54:15 +1000
committerGitHub <noreply@github.com>2021-06-14 08:54:15 -0500
commitdad721d9dc2f3436e3ae4be733a516123e979540 (patch)
tree6959d1c99b2755da1699cc0e653681902c638d86 /lib/ansible/plugins
parenta16dd1150ef1701990ca60c78440aa42d450263a (diff)
downloadansible-dad721d9dc2f3436e3ae4be733a516123e979540.tar.gz
psrp - Fix reset connection on failed scenarios (#74967) (#74984)
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> (cherry picked from commit cf3a304ce1711ed9a19549fbf58c004acd47c06a)
Diffstat (limited to 'lib/ansible/plugins')
-rw-r--r--lib/ansible/plugins/connection/psrp.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ansible/plugins/connection/psrp.py b/lib/ansible/plugins/connection/psrp.py
index 086897b38e..b643c1e485 100644
--- a/lib/ansible/plugins/connection/psrp.py
+++ b/lib/ansible/plugins/connection/psrp.py
@@ -410,7 +410,16 @@ class Connection(ConnectionBase):
def reset(self):
if not self._connected:
+ self.runspace = None
return
+
+ # Try out best to ensure the runspace is closed to free up server side resources
+ try:
+ self.close()
+ except Exception as e:
+ # There's a good chance the connection was already closed so just log the error and move on
+ display.debug("PSRP reset - failed to closed runspace: %s" % to_text(e))
+
display.vvvvv("PSRP: Reset Connection", host=self._psrp_host)
self.runspace = None
self._connect()