@pythoncoder - thanks for your comments. I had modified an earlier version of the mqtt library before it was released and since it has been working in a number of applications I never upgraded to the released version. I haven't had an issue with blocking although the timing in my applications is generally not critical -- I need to periodically break out of a while loop and the timer seemed to be a natural way to do that. The entire code for the mqtt_client is at
https://gist.github.com/slzatz/fed5460f ... 4df9a446a5
One more question: the full timer callback is as follows and works not only with the check_msg line but also includes assigning a float, which, again somewhat surprisingly to me, doesn't cause a memory issue.
Code: Select all
def callback(t):
global MAX_BRIGHT
b = umc.check_msg()
print("b =",b)
if b:
np.fill((0,0,0))
np[0] = (100,0,0)
np.write()
try:
MAX_BRIGHT = float(b[1].decode('ascii'))
except ValueError as e:
print("Value couldn't be converted to float")
tim.init(period=10000, mode=Timer.PERIODIC, callback=callback)