diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index 1b13def5..da0657b5 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -70,6 +70,9 @@ class CoreClient: self.session: Optional[Session] = None self.user = getpass.getuser() + # menu options + self.show_throughputs: tk.BooleanVar = tk.BooleanVar(value=False) + # global service settings self.services: Dict[str, Set[str]] = {} self.config_services_groups: Dict[str, Set[str]] = {} @@ -242,9 +245,10 @@ class CoreClient: logger.warning("unknown node event: %s", event) def enable_throughputs(self) -> None: - self.handling_throughputs = self.client.throughputs( - self.session.id, self.handle_throughputs - ) + if not self.handling_throughputs: + self.handling_throughputs = self.client.throughputs( + self.session.id, self.handle_throughputs + ) def cancel_throughputs(self) -> None: if self.handling_throughputs: @@ -431,13 +435,15 @@ class CoreClient: definition, result, ) + if self.show_throughputs.get(): + self.enable_throughputs() except grpc.RpcError as e: self.app.show_grpc_exception("Start Session Error", e) return result, exceptions def stop_session(self, session_id: int = None) -> bool: - if not session_id: - session_id = self.session.id + session_id = session_id or self.session.id + self.cancel_throughputs() result = False try: result = self.client.stop_session(session_id) diff --git a/daemon/core/gui/menubar.py b/daemon/core/gui/menubar.py index e2df2f92..16e57cb6 100644 --- a/daemon/core/gui/menubar.py +++ b/daemon/core/gui/menubar.py @@ -235,7 +235,11 @@ class Menubar(tk.Menu): menu.add_command( label="Configure Throughput", command=self.click_config_throughput ) - menu.add_checkbutton(label="Enable Throughput?", command=self.click_throughput) + menu.add_checkbutton( + label="Enable Throughput?", + command=self.click_throughput, + variable=self.core.show_throughputs, + ) widget_menu.add_cascade(label="Throughput", menu=menu) def draw_widgets_menu(self) -> None: @@ -393,7 +397,7 @@ class Menubar(tk.Menu): dialog.show() def click_throughput(self) -> None: - if not self.core.handling_throughputs: + if self.core.show_throughputs.get(): self.core.enable_throughputs() else: self.core.cancel_throughputs()