Skip to content

Commit

Permalink
Move telnet sock.settimeout() from _send_cmd_get_resp() to connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
julianneswinoga committed Jan 3, 2024
1 parent 5d02496 commit 620bb28
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flightgear_python/fg_if.py
Expand Up @@ -326,6 +326,8 @@ def connect(self):
self.sock.connect(telnet_addr)
except Exception as e:
raise FGConnectionError(f'Could not connect to FlightGear telnet server {telnet_addr}: {e}') from e

self.sock.settimeout(self.rx_timeout_s)
# force move to the root directory (maybe someone was connected before we were)
_ = self._send_cmd_get_resp('cd /')

Expand All @@ -336,7 +338,6 @@ def _telnet_str(in_str: str) -> ByteString:
def _send_cmd_get_resp(self, cmd_str: str, buflen: int = 512) -> str:
self.sock.sendall(self._telnet_str(cmd_str))

self.sock.settimeout(self.rx_timeout_s)
# FG telnet always ends with a prompt (`cwd`> ), and since we always
# operate relative to the root directory, it should always be the same prompt
ending_bytes = b'/> '
Expand Down

0 comments on commit 620bb28

Please sign in to comment.