while True:
nowTimeIso8601 = strftime("%Y%m%dT%H%M%S%z")
nowTimeUE = strftime("%s")
- nowTemp = read_temp()
- print(str(nowTimeIso8601) + ',' + str(nowTimeUE) + ',' + str(myHostname) + ',' + str(nowTemp), flush=True) # flush to stdout continuously (e.g. without buffer) https://stackoverflow.com/a/14729823
- time.sleep(10)
+ try:
+ nowTemp = read_temp()
+ print(str(nowTimeIso8601) + ',' + str(nowTimeUE) + ',' + str(myHostname) + ',' + str(nowTemp), flush=True) # flush to stdout continuously (e.g. without buffer) https://stackoverflow.com/a/14729823
+ except Exception as e:
+ print(str(nowTimeIso8601) + ',' + str(nowTimeUE) + ',' + str(myHostname) + ',' + 'ERROR:' + str(e), flush=True)
+ finally:
+ time.sleep(10)