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

fix: do not import "server" in client, prevents from having trouble with QApplication creation order

Like with QtWebEngine
This commit is contained in:
2024-06-13 10:03:37 +02:00
committed by wyzula_j
parent 836b6e64f6
commit 6f96498de6
3 changed files with 12 additions and 8 deletions

View File

@ -86,13 +86,8 @@ def _start_plot_process(gui_id, gui_class, config) -> None:
Start the plot in a new process.
"""
# pylint: disable=subprocess-run-check
monitor_module = importlib.import_module("bec_widgets.cli.server")
monitor_path = monitor_module.__file__
command = [
sys.executable,
"-u",
monitor_path,
"bec-gui-server",
"--id",
gui_id,
"--config",
@ -100,7 +95,11 @@ def _start_plot_process(gui_id, gui_class, config) -> None:
"--gui_class",
gui_class.__name__,
]
process = subprocess.Popen(command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
env_dict = os.environ.copy()
env_dict["PYTHONUNBUFFERED"] = "1"
process = subprocess.Popen(
command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env_dict
)
process_output_processing_thread = threading.Thread(target=_get_output, args=(process,))
process_output_processing_thread.start()
return process, process_output_processing_thread

View File

@ -114,7 +114,7 @@ class BECWidgetsCLIServer:
self.client.shutdown()
if __name__ == "__main__": # pragma: no cover
def main():
import argparse
import os
import sys
@ -166,3 +166,7 @@ if __name__ == "__main__": # pragma: no cover
app.aboutToQuit.connect(server.shutdown)
sys.exit(app.exec())
if __name__ == "__main__": # pragma: no cover
main()

View File

@ -48,6 +48,7 @@ Homepage = "https://gitlab.psi.ch/bec/bec_widgets"
[project.scripts]
bw-generate-cli = "bec_widgets.cli.generate_cli:main"
bec-gui-server = "bec_widgets.cli.server:main"
[tool.hatch.build.targets.wheel]
include = ["*"]