Matrix_Portal_Moon_Clock - MemoryError with json.loads
bembengarifin opened this issue · comments
Bembeng Arifin commented
Hi guys,
Initially I kept getting some weird errors about missing midnight property when running the code, but then found that it's actually due to this specific line throwing MemoryError (but swallowed by except)
It seems that converting json from the response string takes quite a memory:
full_data = json.loads(NETWORK.fetch_data(url))
moon_data = full_data['location']['time'][0]
After going through the code, I noticed there is an overload that will enable fetching specific path and return the result in needed json/dictionary object, so simple code change below will solve the problem
location_data = NETWORK.fetch_data(url, json_path=[["location"]])
moon_data = location_data["time"][0]
Hope this helps someone who's getting the same problem as mine
Thanks.
Limor "Ladyada" Fried commented
fixed in latest pr