_tokenPool KeyError in deviceShadow
See original GitHub issueUsing AWSIoTPythonSDK==1.4.3, I’ve caught a KeyError exception inside core.shadow.deviceShadow
2020-06-10 16:27:50,104 [INFO] AWSIoTPythonSDK.core.protocol.mqtt_core: Performing sync publish...
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2913, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1578, in loop_forever
rc = self.loop(timeout, max_packets)
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1072, in loop
rc = self.loop_read(max_packets)
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1374, in loop_read
rc = self._packet_read()
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2071, in _packet_read
rc = self._packet_handle()
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2560, in _packet_handle
return self._handle_publish()
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2759, in _handle_publish
self._handle_on_message(message)
File "/usr/local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2902, in _handle_on_message
callback(self, self._userdata, message)
File "/opt/awsiot-bridge/src/awsiot-bridge.py", line 492, in on_modbus_complete
device_shadow_handler.shadowUpdate(connected=True)
File "/opt/awsiot-bridge/src/shadowmanger.py", line 76, in shadowUpdate
self.client.shadowUpdate(payload_template, self._update, timeout)
File "/usr/local/lib/python3.7/site-packages/AWSIoTPythonSDK/core/shadow/deviceShadow.py", line 362, in shadowUpdate
self._tokenPool[currentToken].start()
KeyError: '71c853b3-4ee3-49ac-a936-cd62e3e5406e'
After reviewing AWSIoTPythonSDK/core/shadow/deviceShadow.py I’m pretty confused as to how the currentToken that was just added to that dictionary could be missing. Seems like there might be a race-condition or some side-effect internal to the library causing this one.
A second set of eyes would be greatly appreciaed!
UPDATE: This issue was just observed again on 2020-06-23
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Device Shadow error messages - AWS IoT Core
The Device Shadow service publishes a message on the error topic (over MQTT) when an attempt to change the state document fails. This...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The fix is now in this Github repo, as well as in PyPI under version 1.4.9. I’ll close out this ticket, but if you see the issue again, just let us know!
I’m working on getting the fix through our release process. Once that happens, it’ll be available here.