Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change append to extend to fix bytestream error #302

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions AWSIoTPythonSDK/core/greengrass/discovery/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def discover(self, thingName):
"""

**Description**

Perform the discovery request for the given Greengrass aware device thing name.

**Syntax**
Expand Down Expand Up @@ -246,9 +246,9 @@ def _create_tcp_connection(self):

def _create_ssl_connection(self, sock):
self._logger.debug("Creating ssl connection...")

ssl_protocol_version = ssl.PROTOCOL_SSLv23

if self._port == 443:
ssl_context = SSLContextBuilder()\
.with_ca_certs(self._ca_path)\
Expand Down 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.append(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:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is always False!

ssl_sock_tmp = []

ssl_sock_tmp is list # False
type(ssl_sock_tmp) is list # True
isinstance(ssl_sock_tmp, list) # True

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @j123b567 - you are right, I just tested using a simple program and it always returns false even if it is a list. I'll make a PR to adjust this so it correctly evaluates the type. Thank you for letting us know!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR made: #307
Thanks again!

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