ci: Fix websocket example test error handling

If connection fails for websocket test, a second exception was generated in
__exit__
This commit is contained in:
Angus Gratton 2020-12-17 14:16:48 +11:00 committed by bot
parent ea476f1731
commit 660f41772c

View File

@ -37,6 +37,7 @@ class Websocket:
self.socket.settimeout(10.0)
self.send_q = queue.Queue()
self.shutdown = Event()
self.conn = None
def __enter__(self):
try:
@ -55,7 +56,8 @@ class Websocket:
self.shutdown.set()
self.server_thread.join()
self.socket.close()
self.conn.close()
if self.conn:
self.conn.close()
def run_server(self):
self.conn, address = self.socket.accept() # accept new connection