From 09d1118a945620487e67ea70ddff9b145399d4ff Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 9 Nov 2020 20:09:56 -0800 Subject: Only close web thread on cleanup if web thread exists, and sleep 1 second when cleaning up MainWindow so loose threads can finish --- desktop/src/onionshare/main_window.py | 4 ++++ desktop/src/onionshare/tab/tab.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/desktop/src/onionshare/main_window.py b/desktop/src/onionshare/main_window.py index 38a6b275..c1e0cd1a 100644 --- a/desktop/src/onionshare/main_window.py +++ b/desktop/src/onionshare/main_window.py @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +import time from PySide2 import QtCore, QtWidgets, QtGui from onionshare_cli.web import Web @@ -286,3 +287,6 @@ class MainWindow(QtWidgets.QMainWindow): def cleanup(self): self.tabs.cleanup() self.common.gui.onion.cleanup() + + # Wait 1 second for threads to close gracefully, so tests finally pass + time.sleep(1) diff --git a/desktop/src/onionshare/tab/tab.py b/desktop/src/onionshare/tab/tab.py index b5e4e6a8..5e819405 100644 --- a/desktop/src/onionshare/tab/tab.py +++ b/desktop/src/onionshare/tab/tab.py @@ -663,6 +663,7 @@ class Tab(QtWidgets.QWidget): return False def cleanup(self): - self.get_mode().web_thread.quit() - self.get_mode().web_thread.wait() + if self.get_mode() and self.get_mode().web_thread: + self.get_mode().web_thread.quit() + self.get_mode().web_thread.wait() self.app.cleanup() -- cgit v1.2.3-54-g00ecf