is pycom.rgbled thread safe?

  • I modified the Pycom AWS MQTT library and put an LED blink into the transmit routine:

            if self._ping_failures == 0:
                if self._out_packet_mutex.locked() and len(self._output_queue) > 0:
                    pycom.rgbled(0xff0000) # red
                    if self._send_packet(packet):
                        if self.wdt is not None:
                        pycom.rgbled(0x000010) # dark blue

    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?

Pycom on Twitter