From 425b31da84009f3f0ea2387d7c2ae3d6a6966982 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Tue, 9 Aug 2022 15:06:59 +0530 Subject: [PATCH] Remove semophores and add even in kivysignaler --- src/bitmessagekivy/kivy_state.py | 5 ++++- src/bitmessagekivy/mpybit.py | 2 +- src/bitmessagekivy/uikivysignaler.py | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bitmessagekivy/kivy_state.py b/src/bitmessagekivy/kivy_state.py index 0c8bc4c5..a813bd06 100644 --- a/src/bitmessagekivy/kivy_state.py +++ b/src/bitmessagekivy/kivy_state.py @@ -5,6 +5,8 @@ Kivy State variables are assigned here, they are separated from state.py ================================= """ +import threading + class KivyStateVariables(object): """This Class hold all the kivy state variables""" @@ -34,4 +36,5 @@ class KivyStateVariables(object): self.in_sent_method = False self.in_search_mode = False self.imageDir = None - self.sqlReady = False # set to true by sqlTread when ready for processing + # self.sqlReady = False # set to true by sqlTread when ready for processing + self.sql_ready = threading.Event() diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index aaec2cf4..001b7859 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -257,7 +257,7 @@ class NavigateApp(MDApp): def run(self): """Running the widgets""" - kivyuisignaler.release() + self.kivy_state_obj.sql_ready.set() super(NavigateApp, self).run() @staticmethod diff --git a/src/bitmessagekivy/uikivysignaler.py b/src/bitmessagekivy/uikivysignaler.py index 35376112..92829adc 100644 --- a/src/bitmessagekivy/uikivysignaler.py +++ b/src/bitmessagekivy/uikivysignaler.py @@ -6,13 +6,19 @@ from threading import Thread import queues import state from semaphores import kivyuisignaler +from bitmessagekivy.baseclass.common import kivy_state_variables class UIkivySignaler(Thread): """Kivy ui signaler""" + def __init__(self, *args, **kwargs): + super(UIkivySignaler, self).__init__(*args, **kwargs) + self.kivy_state = kivy_state_variables() + def run(self): - kivyuisignaler.acquire() + self.kivy_state.sql_ready.wait() + # kivyuisignaler.acquire() while state.shutdown == 0: try: command, data = queues.UISignalQueue.get()