Closed jerryneedell closed 5 years ago
oosps yeah this is my current loop
while True:
try:
display.print('----')
# Connect to WiFi if not already
print("Connected to", esp.remote_AP)
if esp.remote_AP[0] != MY_SSID:
esp.join_AP(MY_SSID, MY_PASS)
print("My IP Address:", esp.local_ip)
# great, lets get the JSON data
print("Retrieving price...", end='')
header, body = esp.request_url(URL)
print("OK")
except RuntimeError as e:
print("Failed to connect, retrying")
print(e)
continue
try:
print("Parsing JSON response...", end='')
json = ujson.loads(body)
bitcoin = json["bpi"]["USD"]["rate_float"]
print("USD per bitcoin:", bitcoin)
display.print(int(bitcoin))
except ValueError:
print("Failed to parse json, retrying")
continue
gc.collect()
print("Free memory:", gc.mem_free() / 1024)
time.sleep(15)
fix with try/except
FYI - I've seen this a few times while running the bitcoin test.
Probably just a garbled message and we just need to catch the exception. Have you run into it?
just realized it is in the "simpletest" not the library -- should be easy to do a try/except bc.py is just my local copy of the bitcoin simpletest.