2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Cancel the recvr task on close

This avoids stail recvr from sending duplicate data.
This commit is contained in:
Jarrod Johnson 2024-08-21 09:12:18 -04:00
parent dd2119c6d9
commit cbd457b464

View File

@ -119,6 +119,7 @@ class TsmConsole(conapi.Console):
self.datacallback = None
self.nodeconfig = config
self.connected = False
self.recvr = None
def recvdata(self):
@ -148,13 +149,16 @@ class TsmConsole(conapi.Console):
self.ws.set_verify_callback(kv)
self.ws.connect('wss://{0}/console0'.format(self.bmc), host=bmc, cookie='XSRF-TOKEN={0}; SESSION={1}'.format(wc.cookies['XSRF-TOKEN'], wc.cookies['SESSION']), subprotocols=[wc.cookies['XSRF-TOKEN']])
self.connected = True
eventlet.spawn_n(self.recvdata)
self.recvr = eventlet.spawn(self.recvdata)
return
def write(self, data):
self.ws.send(data)
def close(self):
if self.recvr:
self.recvr.kill()
self.recvr = None
if self.ws:
self.ws.close()
self.connected = False