mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31: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:
@ -86,13 +86,8 @@ def _start_plot_process(gui_id, gui_class, config) -> None:
|
|||||||
Start the plot in a new process.
|
Start the plot in a new process.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=subprocess-run-check
|
# pylint: disable=subprocess-run-check
|
||||||
monitor_module = importlib.import_module("bec_widgets.cli.server")
|
|
||||||
monitor_path = monitor_module.__file__
|
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
sys.executable,
|
"bec-gui-server",
|
||||||
"-u",
|
|
||||||
monitor_path,
|
|
||||||
"--id",
|
"--id",
|
||||||
gui_id,
|
gui_id,
|
||||||
"--config",
|
"--config",
|
||||||
@ -100,7 +95,11 @@ def _start_plot_process(gui_id, gui_class, config) -> None:
|
|||||||
"--gui_class",
|
"--gui_class",
|
||||||
gui_class.__name__,
|
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 = threading.Thread(target=_get_output, args=(process,))
|
||||||
process_output_processing_thread.start()
|
process_output_processing_thread.start()
|
||||||
return process, process_output_processing_thread
|
return process, process_output_processing_thread
|
||||||
|
@ -114,7 +114,7 @@ class BECWidgetsCLIServer:
|
|||||||
self.client.shutdown()
|
self.client.shutdown()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__": # pragma: no cover
|
def main():
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -166,3 +166,7 @@ if __name__ == "__main__": # pragma: no cover
|
|||||||
|
|
||||||
app.aboutToQuit.connect(server.shutdown)
|
app.aboutToQuit.connect(server.shutdown)
|
||||||
sys.exit(app.exec())
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": # pragma: no cover
|
||||||
|
main()
|
||||||
|
@ -48,6 +48,7 @@ Homepage = "https://gitlab.psi.ch/bec/bec_widgets"
|
|||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
bw-generate-cli = "bec_widgets.cli.generate_cli:main"
|
bw-generate-cli = "bec_widgets.cli.generate_cli:main"
|
||||||
|
bec-gui-server = "bec_widgets.cli.server:main"
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
include = ["*"]
|
include = ["*"]
|
||||||
|
Reference in New Issue
Block a user