Skip to content

Commit a71436e

Browse files
committed
socket_comms: wait for connection properly
Don't return early if `self.receive` returns NULL. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 367bffd commit a71436e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/infuse_iot/socket_comms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ def connection_create(self, infuse_id: int, data_types: GatewayRequestConnection
242242
req = GatewayRequestConnectionRequest(infuse_id, data_types)
243243
self.send(req)
244244
# Wait for response from the server
245-
while rsp := self.receive():
246-
if isinstance(rsp, ClientNotificationConnectionCreated):
247-
return rsp.max_payload
248-
elif isinstance(rsp, ClientNotificationConnectionFailed):
249-
raise ConnectionRefusedError
250-
raise ConnectionRefusedError
245+
while True:
246+
if rsp := self.receive():
247+
if isinstance(rsp, ClientNotificationConnectionCreated):
248+
return rsp.max_payload
249+
elif isinstance(rsp, ClientNotificationConnectionFailed):
250+
raise ConnectionRefusedError
251251

252252
def connection_release(self):
253253
assert self._connection_id is not None

0 commit comments

Comments
 (0)