add timeout to send

This commit is contained in:
Ilya Uraev 2025-05-23 14:54:12 +03:00
parent 4ebd4a6206
commit fb7ededef7

View file

@ -73,13 +73,13 @@ class RobotClient:
print(f"{RED}DEBUG: Exception in recv loop: {e}{RESET}")
break
def _send_single_json(self, cmd) -> dict:
def _send_single_json(self, cmd, timeout=5.0) -> dict:
if DEBUG:
print(f"{CYAN}DEBUG: sended:{RESET} {cmd}")
self.sock.sendall(json.dumps(cmd).encode("utf-8"))
try:
response = self._response_queue.get(timeout=5)
response = self._response_queue.get(timeout=timeout)
try:
extra = self._response_queue.get_nowait()
raise RuntimeError(
@ -170,7 +170,7 @@ class RobotClient:
def move_line(self, joint_radian: list) -> None:
cmd = {"command": "move_line", "joint_radian": joint_radian}
ret = self._send_single_json(cmd)
ret = self._send_single_json(cmd, 10.0)
if (ret.get("ret") != 0):
raise RuntimeError(f"move_line failed: {ret}")
self.wait_untill_motion_is_done(10.0)