Merge "Add destructor for SshAgent"

This commit is contained in:
Zuul 2020-03-03 18:29:01 +00:00 committed by Gerrit Code Review
commit 83af405ca7
1 changed files with 10 additions and 0 deletions

View File

@ -267,6 +267,16 @@ class SshAgent(object):
self.log.debug('Sent SIGTERM to SSH Agent, {}'.format(self.env))
self.env = {}
def __del__(self):
try:
self.stop()
except Exception:
self.log.exception('Exception in SshAgent destructor')
try:
super().__del__(self)
except AttributeError:
pass
def add(self, key_path):
env = os.environ.copy()
env.update(self.env)