Remove watchdog, replace with a simple background thread

This commit is contained in:
Micah Lee 2020-04-06 19:26:45 -07:00
parent e84ca43da8
commit a9d55e9169
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
5 changed files with 90 additions and 129 deletions

View file

@ -18,13 +18,12 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from PyQt5 import QtCore, QtWidgets, QtGui
from watchdog.observers import Observer
from onionshare import strings
from onionshare.mode_settings import ModeSettings
from .tab import Tab
from .event_handler import EventHandler
from .threads import EventHandlerThread
class TabWidget(QtWidgets.QTabWidget):
@ -72,17 +71,15 @@ class TabWidget(QtWidgets.QTabWidget):
self.move_new_tab_button()
# Watch the events file for changes
self.event_handler = EventHandler(common)
self.event_handler.new_tab.connect(self.add_tab)
self.event_handler.new_share_tab.connect(self.new_share_tab)
self.observer = Observer()
self.observer.schedule(self.event_handler, self.common.gui.events_dir)
self.observer.start()
self.event_handler_t = EventHandlerThread(common)
self.event_handler_t.new_tab.connect(self.add_tab)
self.event_handler_t.new_share_tab.connect(self.new_share_tab)
self.event_handler_t.start()
def cleanup(self):
# Stop the event thread
self.observer.stop()
self.observer.join()
self.event_handler_t.stop()
self.event_handler_t.join()
# Clean up each tab
for index in range(self.count()):