Performance: Action client with feedback
This concept affects the responsiveness and smoothness of user interactions by managing how feedback messages are processed and rendered during action execution.
import threading def feedback_cb(feedback): threading.Thread(target=process_feedback, args=(feedback,)).start() client.send_goal(goal, feedback_cb=feedback_cb) # Feedback callback quickly delegates work to a separate thread
def feedback_cb(feedback): print(f"Feedback received: {feedback.progress}") client.send_goal(goal, feedback_cb=feedback_cb) # Feedback callback does heavy processing or blocking operations
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Blocking feedback callback | N/A | N/A | Delays UI update | [X] Bad |
| Non-blocking feedback callback with threading | N/A | N/A | Smooth UI update | [OK] Good |
def feedback_cb(feedback):
print(f"Progress: {feedback.progress}%")
client = actionlib.SimpleActionClient('task', TaskAction)
client.wait_for_server()
goal = TaskGoal()
client.send_goal(goal, feedback_cb=feedback_cb)client = actionlib.SimpleActionClient('task', TaskAction)
client.send_goal(TaskGoal(), feedback_cb=feedback_cb)
client.wait_for_server()Pass the test and this pattern moves unknown