Agent: Move keep_connection into the run() method

This commit is contained in:
Kekoa Kaaikala 2022-09-06 14:03:17 +00:00
parent 333e587aab
commit d7398e1014
1 changed files with 4 additions and 4 deletions

View File

@ -20,14 +20,14 @@ class SocketsPipe(Thread):
self.source = source self.source = source
self.dest = dest self.dest = dest
self.timeout = timeout self.timeout = timeout
self._keep_connection = True
super().__init__(name=f"SocketsPipeThread-{self.ident}", daemon=True) super().__init__(name=f"SocketsPipeThread-{self.ident}", daemon=True)
self._client_disconnected = client_disconnected self._client_disconnected = client_disconnected
def run(self): def run(self):
sockets = [self.source, self.dest] sockets = [self.source, self.dest]
while self._keep_connection: keep_connection = True
self._keep_connection = False while keep_connection:
keep_connection = False
rlist, _, xlist = select.select(sockets, [], sockets, self.timeout) rlist, _, xlist = select.select(sockets, [], sockets, self.timeout)
if xlist: if xlist:
break break
@ -42,7 +42,7 @@ class SocketsPipe(Thread):
other.sendall(data) other.sendall(data)
except Exception: except Exception:
break break
self._keep_connection = True keep_connection = True
self.source.close() self.source.close()
self.dest.close() self.dest.close()