add timeout to send
This commit is contained in:
parent
4ebd4a6206
commit
fb7ededef7
1 changed files with 3 additions and 3 deletions
6
utils.py
6
utils.py
|
@ -73,13 +73,13 @@ class RobotClient:
|
||||||
print(f"{RED}DEBUG: Exception in recv loop: {e}{RESET}")
|
print(f"{RED}DEBUG: Exception in recv loop: {e}{RESET}")
|
||||||
break
|
break
|
||||||
|
|
||||||
def _send_single_json(self, cmd) -> dict:
|
def _send_single_json(self, cmd, timeout=5.0) -> dict:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(f"{CYAN}DEBUG: sended:{RESET} {cmd}")
|
print(f"{CYAN}DEBUG: sended:{RESET} {cmd}")
|
||||||
self.sock.sendall(json.dumps(cmd).encode("utf-8"))
|
self.sock.sendall(json.dumps(cmd).encode("utf-8"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = self._response_queue.get(timeout=5)
|
response = self._response_queue.get(timeout=timeout)
|
||||||
try:
|
try:
|
||||||
extra = self._response_queue.get_nowait()
|
extra = self._response_queue.get_nowait()
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
|
@ -170,7 +170,7 @@ class RobotClient:
|
||||||
|
|
||||||
def move_line(self, joint_radian: list) -> None:
|
def move_line(self, joint_radian: list) -> None:
|
||||||
cmd = {"command": "move_line", "joint_radian": joint_radian}
|
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):
|
if (ret.get("ret") != 0):
|
||||||
raise RuntimeError(f"move_line failed: {ret}")
|
raise RuntimeError(f"move_line failed: {ret}")
|
||||||
self.wait_untill_motion_is_done(10.0)
|
self.wait_untill_motion_is_done(10.0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue