psrp - Fix reset connection on failed scenarios (#74967) (#74983)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit cf3a304ce1)
pull/75004/head
Jordan Borean 4 years ago committed by GitHub
parent 8aa850e357
commit c6d647a8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- psrp - Fix error when resetting a connection that was initialised but not connected - (https://github.com/ansible/ansible/issues/74092).
- psrp - Try to clean up any server-side resources when resetting a connection.

@ -408,7 +408,16 @@ class Connection(ConnectionBase):
def reset(self): def reset(self):
if not self._connected: if not self._connected:
self.runspace = None
return 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) display.vvvvv("PSRP: Reset Connection", host=self._psrp_host)
self.runspace = None self.runspace = None
self._connect() self._connect()

Loading…
Cancel
Save