is pycom.rgbled thread safe?
-
I modified the Pycom AWS MQTT library and put an LED blink into the transmit routine:
self._out_packet_mutex.acquire() if self._ping_failures == 0: if self._out_packet_mutex.locked() and len(self._output_queue) > 0: packet=self._output_queue[0] pycom.rgbled(0xff0000) # red if self._send_packet(packet): self._output_queue.pop(0) if self.wdt is not None: self.wdt.feed() pycom.rgbled(0x000010) # dark blue self._out_packet_mutex.release()
Also, I feed the WDT here so the Wipy gets a reset in case of a connection loss. As the MQTT library starts a thread for this transmit routine and I also set the LED from the main code (running in parallel), could there be the case that the main code is interrupted while executing a pycom.rgbled and then pycom.rgbled be called in the transmit thread? Is it safe to do so? Or would I need to encapsulate the LED update with another mutex?