Adding connection wait for connected status to new_connection.

This commit is contained in:
Michael Woods
2025-02-15 15:47:28 -05:00
parent dcf97a01f0
commit 811c608213

View File

@@ -50,8 +50,12 @@ class Client:
if not ax25.Address.valid_call(dest): if not ax25.Address.valid_call(dest):
raise ValueError(f"Provided destination callsign '{dest}' is invalid.") raise ValueError(f"Provided destination callsign '{dest}' is invalid.")
conn = self.app.open_connection(0, self.callsign, dest) conn = self.app.open_connection(0, self.callsign, dest)
logging.debug("Allowing connection to stabilize for 3 seconds") while conn.state.name != "CONNECTED":
time.sleep(8) if conn.state.name in ['DISCONNECTED', 'DISCONNECTING']:
raise RuntimeError("Connection disconnected unexpectedly.")
time.sleep(.1)
logging.debug("Allowing connection to stabilize for 10 seconds")
time.sleep(10)
return conn return conn
def send_and_receive(self, req: Request, conn: PacketServerConnection, timeout: int = 300) -> Optional[Response]: def send_and_receive(self, req: Request, conn: PacketServerConnection, timeout: int = 300) -> Optional[Response]: