From 9ee372e6f0844977c408fbaf9c6d86ac36b42058 Mon Sep 17 00:00:00 2001 From: ansonnn Date: Fri, 4 Feb 2022 15:36:34 +0800 Subject: [PATCH] Fix: Change dobot demo from Process to Thread --- src/lib/dobot_arm_demo/main.py | 12 ++++++------ .../sub_pages/deployment_page/deployment_page.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/dobot_arm_demo/main.py b/src/lib/dobot_arm_demo/main.py index b050224a..2b78f2c2 100644 --- a/src/lib/dobot_arm_demo/main.py +++ b/src/lib/dobot_arm_demo/main.py @@ -12,8 +12,8 @@ else: from .dobot_api import dobot_api_dashboard, dobot_api_feedback, MyType -# from threading import Thread -from multiprocessing import Process +from threading import Thread +# from multiprocessing import Process import numpy as np from time import sleep @@ -328,7 +328,7 @@ def move_and_publish_view(client_dashboard: dobot_api_dashboard, client_feedback DobotTask.P2_140: move_for_p2_140 } - client = get_mqtt_client() + client = get_mqtt_client('dobot_demo') client.connect(conf.broker, port=conf.port) client.loop_start() @@ -401,7 +401,7 @@ def data_feedback(client_feedback: dobot_api_feedback): print('q_actual', np.around(a['q_actual'], decimals=4)) -def run(conf: MQTTConfig, task: DobotTask = DobotTask.Box) -> Tuple[bool, Process]: +def run(conf: MQTTConfig, task: DobotTask = DobotTask.Box) -> Tuple[bool, Thread]: if task == DobotTask.DEBUG: logger.debug("Running debug publishing") move_fn = debug_publish @@ -419,13 +419,13 @@ def run(conf: MQTTConfig, task: DobotTask = DobotTask.Box) -> Tuple[bool, Proces move_fn = move_and_publish_view args = (client_dashboard, client_feedback, conf, task) - p1 = Process(target=move_fn, args=args) + p1 = Thread(target=move_fn, args=args) p1.start() return True, p1 # Not using all these for our vision inspection app - # p2 = Process(target=data_feedback, args=(client_feedback,)) + # p2 = Thread(target=data_feedback, args=(client_feedback,)) # p2.daemon = True # p2.start() # p1.join() diff --git a/src/lib/pages/sub_pages/deployment_page/deployment_page.py b/src/lib/pages/sub_pages/deployment_page/deployment_page.py index f0398a53..7179a1f3 100644 --- a/src/lib/pages/sub_pages/deployment_page/deployment_page.py +++ b/src/lib/pages/sub_pages/deployment_page/deployment_page.py @@ -1602,9 +1602,9 @@ def update_publish_frame_conf(publish_frame: bool): # and reset back to None session_state.check_labels = None logger.info("Label checking process has finished") - if dobot_process is not None: - # gracefully kill the dobot_demo's Process - dobot_process.kill() + # if dobot_process is not None: + # # gracefully kill the dobot_demo's Process + # dobot_process.kill() continue if use_multi_cam: