Closed
Description
Preconditions:
- Two Device shadows are associated (as in a gateway scenerio), but no update has been sent so the
update/accepted
andupdate/rejected
topics are not yet subscribed to.
Process to Re-Create:
- Remove connectivity from the library
- Attempt to update one of the shadows, receive a subscribeTimoutException
- Attempt to update the second shadow
Result
The call to update the second shadow never returns. The offending call is here:
def basicShadowSubscribe(self, srcShadowName, srcShadowAction, srcCallback):
self._shadowSubUnsubOperationLock.acquire()
currentShadowAction = _shadowAction(srcShadowName, srcShadowAction)
if currentShadowAction.isDelta:
self._mqttCoreHandler.subscribe(currentShadowAction.getTopicDelta(), 0, srcCallback)
else:
self._mqttCoreHandler.subscribe(currentShadowAction.getTopicAccept(), 0, srcCallback)
self._mqttCoreHandler.subscribe(currentShadowAction.getTopicReject(), 0, srcCallback)
time.sleep(2)
self._shadowSubUnsubOperationLock.release()
On line 68 a lock is acquired. Notice that on lines 71, 73, and 74, a subscribeTimeoutException may be raised (as happened in the second step to recreate), jumping past the lock release call on line 76. Any cases of locks being acquired/released should be using context managers or exception handling to ensure that the lock is released if an operation fails.
Metadata
Metadata
Assignees
Labels
No labels