Add destructor for SshAgent
There is no indication this is necessary (it seems all code paths do result in stop() being called), but just in case, add a destructor to SshAgent to make sure we don't leave an ssh-agent process running beyond the end of a job. Change-Id: I10172574d0844e7181a82ae586121e6ba5e3d6ff
This commit is contained in:
parent
bbe2d36495
commit
6c72f6d3dd
|
@ -260,6 +260,16 @@ class SshAgent(object):
|
||||||
self.log.debug('Sent SIGTERM to SSH Agent, {}'.format(self.env))
|
self.log.debug('Sent SIGTERM to SSH Agent, {}'.format(self.env))
|
||||||
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):
|
def add(self, key_path):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env.update(self.env)
|
env.update(self.env)
|
||||||
|
|
Loading…
Reference in New Issue