diff --git a/client/brewpi_gui.py b/client/brewpi_gui.py index 8805b6b..de2f094 100755 --- a/client/brewpi_gui.py +++ b/client/brewpi_gui.py @@ -3,6 +3,7 @@ from main_window import Ui_MainWindow from PyQt5 import QtWidgets, QtGui, QtCore import json import sys +import threading import time import matplotlib matplotlib.use("Qt5Agg") @@ -246,7 +247,12 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): self.plot_power_set, self.plot_power_eff) def disconnect(self): - self.ws_client.disconnect() + # ws_client.disconnect() blocks until the websocket's close handshake + # completes (or times out, ~10s if the server doesn't ack promptly), + # joining the connection's background thread - run it off a throwaway + # thread so that wait doesn't freeze the GUI. on_ws_connect_changed() + # still flips the button once the disconnect actually finishes. + threading.Thread(target=self.ws_client.disconnect, daemon=True).start() def on_btn_connect_clicked(self): if self.connected: