Mercurial > libervia-backend
changeset 2840:0f277708e2ae
bridge (pb): added bridgeDeactivateSignals and bridgeReactivateSignals methods:
those methods stop and restart signals propagation, they are used on mobile OS when the frontend is paused.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 09 Mar 2019 16:23:00 +0100 |
parents | 76f714b12d21 |
children | 90115cf4e731 |
files | sat/bridge/bridge_constructor/constructors/pb/pb_core_template.py sat/bridge/pb.py |
diffstat | 2 files changed, 62 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/bridge/bridge_constructor/constructors/pb/pb_core_template.py Sun Mar 03 20:59:29 2019 +0100 +++ b/sat/bridge/bridge_constructor/constructors/pb/pb_core_template.py Sat Mar 09 16:23:00 2019 +0100 @@ -69,6 +69,24 @@ log.debug(u"Removing signal handler for dead frontend") self.signals_handlers.remove(handler) + def _bridgeDeactivateSignals(self): + if hasattr(self, "signals_paused"): + log.warning(u"bridge signals already deactivated") + if self.signals_handler: + self.signals_paused.extend(self.signals_handler) + else: + self.signals_paused = self.signals_handlers + self.signals_handlers = [] + log.debug(u"bridge signals have been deactivated") + + def _bridgeReactivateSignals(self): + try: + self.signals_handlers = self.signals_paused + except AttributeError: + log.debug(u"signals were already activated") + else: + del self.signals_paused + log.debug(u"bridge signals have been reactivated") ##METHODS_PART## @@ -103,5 +121,18 @@ self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs) ) + def bridgeDeactivateSignals(self): + """Stop sending signals to bridge + + Mainly used for mobile frontends, when the frontend is paused + """ + self.root._bridgeDeactivateSignals() + + def bridgeReactivateSignals(self): + """Send again signals to bridge + + Should only be used after bridgeDeactivateSignals has been called + """ + self.root._bridgeReactivateSignals() ##SIGNALS_PART##
--- a/sat/bridge/pb.py Sun Mar 03 20:59:29 2019 +0100 +++ b/sat/bridge/pb.py Sat Mar 09 16:23:00 2019 +0100 @@ -69,6 +69,24 @@ log.debug(u"Removing signal handler for dead frontend") self.signals_handlers.remove(handler) + def _bridgeDeactivateSignals(self): + if hasattr(self, "signals_paused"): + log.warning(u"bridge signals already deactivated") + if self.signals_handler: + self.signals_paused.extend(self.signals_handler) + else: + self.signals_paused = self.signals_handlers + self.signals_handlers = [] + log.debug(u"bridge signals have been deactivated") + + def _bridgeReactivateSignals(self): + try: + self.signals_handlers = self.signals_paused + except AttributeError: + log.debug(u"signals were already activated") + else: + del self.signals_paused + log.debug(u"bridge signals have been reactivated") ##METHODS_PART## @@ -103,6 +121,19 @@ self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs) ) + def bridgeDeactivateSignals(self): + """Stop sending signals to bridge + + Mainly used for mobile frontends, when the frontend is paused + """ + self.root._bridgeDeactivateSignals() + + def bridgeReactivateSignals(self): + """Send again signals to bridge + + Should only be used after bridgeDeactivateSignals has been called + """ + self.root._bridgeReactivateSignals() def actionNew(self, action_data, id, security_limit, profile): self.sendSignal("actionNew", action_data, id, security_limit, profile)