Skip to content

Commit deb7e15

Browse files
committed
update suback packet
1 parent 7277872 commit deb7e15

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

AWSIoTPythonSDK/core/protocol/mqtt_core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
from queue import Queue
6060

6161

62-
class AckPacket(object):
62+
class SubackPacket(object):
6363
def __init__(self):
6464
self.event = Event()
6565
self.data = None
@@ -305,15 +305,15 @@ def subscribe(self, topic, qos, message_callback=None):
305305
if ClientStatus.STABLE != self._client_status.get_status():
306306
self._handle_offline_request(RequestTypes.SUBSCRIBE, (topic, qos, message_callback, None))
307307
else:
308-
ack = AckPacket()
309-
rc, mid = self._subscribe_async(topic, qos, self._create_blocking_ack_callback_ret(ack), message_callback)
310-
if not ack.event.wait(self._operation_timeout_sec):
308+
suback = SubackPacket()
309+
rc, mid = self._subscribe_async(topic, qos, self._create_blocking_suback_callback(suback), message_callback)
310+
if not suback.event.wait(self._operation_timeout_sec):
311311
self._internal_async_client.remove_event_callback(mid)
312312
self._logger.error("Subscribe timed out")
313313
raise subscribeTimeoutException()
314-
if ack.data[0] == MQTT_ERR_SUBACK_ERROR:
315-
self._logger.error(f"Subscribe error: {ack.data}")
316-
raise subscribeError(ack.data)
314+
if suback.data and suback.data[0] == MQTT_ERR_SUBACK_ERROR:
315+
self._logger.error(f"Subscribe error: {suback.data}")
316+
raise subscribeError(suback.data)
317317
ret = True
318318
return ret
319319

@@ -371,7 +371,7 @@ def ack_callback(mid, data=None):
371371
event.set()
372372
return ack_callback
373373

374-
def _create_blocking_ack_callback_ret(self, ack: AckPacket):
374+
def _create_blocking_suback_callback(self, ack: SubackPacket):
375375
def ack_callback(mid, data=None):
376376
ack.data = data
377377
ack.event.set()

0 commit comments

Comments
 (0)