Add exit handling
parent
d17ecc9806
commit
b884a180c8
|
@ -80,32 +80,41 @@ class Runner(threading.Thread):
|
|||
if self.shell_channel in r:
|
||||
x = self.shell_channel.recv(1024)
|
||||
if len(x) == 0:
|
||||
break
|
||||
self.shell_channel = None
|
||||
client_shell_channel.send(x)
|
||||
if client_shell_channel in r:
|
||||
x = client_shell_channel.recv(1024)
|
||||
if len(x) == 0:
|
||||
break
|
||||
self.shell_channel = None
|
||||
self.shell_channel.send(x)
|
||||
|
||||
if self.sftp_channel is not None: # TODO: move this to function
|
||||
if self.sftp_channel is not None: # TODO: move this to function
|
||||
r, w, e = select.select([client_sftp_channel, self.sftp_channel], [], [])
|
||||
if self.sftp_channel in r:
|
||||
x = self.sftp_channel.recv(1024)
|
||||
if len(x) == 0:
|
||||
break
|
||||
self.sftp_channel = None
|
||||
client_sftp_channel.send(x)
|
||||
if client_sftp_channel in r:
|
||||
x = client_sftp_channel.recv(1024)
|
||||
if len(x) == 0:
|
||||
break
|
||||
self.sftp_channel = None
|
||||
self.sftp_channel.send(x)
|
||||
|
||||
if self.transport.is_active() is False:
|
||||
break
|
||||
|
||||
client_shell_channel.close()
|
||||
self.shell_channel.close()
|
||||
try:
|
||||
client_shell_channel.close()
|
||||
self.shell_channel.close()
|
||||
except AttributeError as e:
|
||||
logger.debug(e)
|
||||
try:
|
||||
client_sftp_channel.close()
|
||||
self.sftp_channel.close()
|
||||
except AttributeError as e:
|
||||
logger.debug(e)
|
||||
|
||||
lxd_interface.destroy_instance(self.instance_name)
|
||||
|
||||
def set_shell_channel(self, channel):
|
||||
|
|
Loading…
Reference in New Issue