inputs, outputs, errors = select.select(r_socks, w_socks, r_socks, 0.01) if len(errors) > 0: logging.error("Socket error while executing select") if mqtt_sock in inputs: rc = mqtt_client.loop_read() mqtt_lib.read() if rc or mqtt_sock is None: logging.error("mqtt read error") if mqtt_sock in outputs: rc = mqtt_client.loop_write() if rc or mqtt_sock is None: logging.error("mqtt write error") if esp_sock in inputs: rc = esp_lib.read(esp_sock, esp_write_queue) if rc != 0: logging.error("esp socket read error") # update esp time esp_lib.update_time_and_ping() if esp_sock in outputs: while not esp_write_queue.empty(): msg = esp_write_queue.get() esp_sock.sendto(*msg) mqtt_client.loop_misc() data_collector()