0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

fix(rpc): trigger shutdown of server when gui is terminated

This commit is contained in:
2024-06-25 16:07:09 +02:00
parent f75fc19c5b
commit acc13183e2
3 changed files with 13 additions and 1 deletions

View File

@ -208,6 +208,7 @@ class BECGuiClientMixin:
self._process.terminate()
if self._process_output_processing_thread:
self._process_output_processing_thread.join()
self._process.wait()
self._process = None

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import inspect
import signal
import sys
@ -29,7 +31,7 @@ class BECWidgetsCLIServer:
dispatcher: BECDispatcher = None,
client=None,
config=None,
gui_class: Union["BECFigure", "BECDockArea"] = BECFigure,
gui_class: Union[BECFigure, BECDockArea] = BECFigure,
) -> None:
self.dispatcher = BECDispatcher(config=config) if dispatcher is None else dispatcher
self.client = self.dispatcher.client if client is None else client
@ -118,6 +120,7 @@ class BECWidgetsCLIServer:
def shutdown(self): # TODO not sure if needed when cleanup is done at level of BECConnector
self._shutdown_event = True
self._heartbeat_timer.stop()
self.gui.close()
self.client.shutdown()
@ -207,6 +210,7 @@ def main():
app.quit()
signal.signal(signal.SIGINT, sigint_handler)
signal.signal(signal.SIGTERM, sigint_handler)
sys.exit(app.exec())

View File

@ -72,6 +72,13 @@ class VSCodeEditor(WebsiteWidget):
self.cleanup_vscode()
return super().cleanup()
def close(self):
"""
Close the widget.
"""
self.cleanup_vscode()
return super().close()
if __name__ == "__main__": # pragma: no cover
import sys