Skip to content

Commit

Permalink
correctly handle bytearray with extend or append
Browse files Browse the repository at this point in the history
  • Loading branch information
jmklix committed Mar 1, 2022
1 parent dd4a464 commit 4b80923
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion AWSIoTPythonSDK/core/greengrass/discovery/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,14 @@ def _receive_until(self, ssl_sock, criteria_function, extra_data=None):
start_time = time.time()
response = bytearray()
number_bytes_read = 0
ssl_sock_tmp = None
while True: # Python does not have do-while
try:
response.extend(self._convert_to_int_py3(ssl_sock.read(1)))
ssl_sock_tmp = self._convert_to_int_py3(ssl_sock.read(1))
if ssl_sock_tmp is list:
response.extend(ssl_sock_tmp)
else:
response.append(ssl_sock_tmp)
number_bytes_read += 1
except socket.error as err:
if err.errno == ssl.SSL_ERROR_WANT_READ or err.errno == ssl.SSL_ERROR_WANT_WRITE:
Expand Down

0 comments on commit 4b80923

Please sign in to comment.