adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 37 forks source link

Version 1.7.x breaks use with MatrixPortal projects because it can't read JSON #39

Closed makermelissa closed 4 years ago

makermelissa commented 4 years ago

When trying out the OpenWeather Demo (https://learn.adafruit.com/weather-display-matrix/code-the-weather-display-matrix), it works as expected with version 1.6.0 and breaks when updating to 1.7.x.

The lines I noticed related to the error that keep repeating:

Free mem:  31664
Retrieving data...Socket missing recv_into. Using more memory to be compatible
Reply is OK!
{"coord":{"lon":-118.24,"lat":34.05},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50d"}],"base":"stations","main":{"temp":27.55,"feels_like":30.38,"temp_min":21,"temp_max":31.11,"pressure":1016,"humidity":64},"visibility":6437,"wind":{"speed":1.31,"deg":212},"clouds":{"all":1},"dt":1601921273,"sys":{"type":1,"id":3694,"country":"US","sunrise":1601905840,"sunset":1601947886},"timezone":-25200,"id":5368361,"name":"Los Angeles","cod":200}
Some error occured, retrying! - Cannot access json after getting text or content
makermelissa commented 4 years ago

Ok, I looked into this. The issue is we are grabbing request.text and then request.json() and this causes the error. I'll update the MatrixPortal library to not do this.

makermelissa commented 4 years ago

This issue likely affects Adafruit_CircuitPython_PyPortal and possibly Adafruit_Blinka_PyPortal as well.

tannewt commented 4 years ago

I did this to avoid holding onto the full string memory between the text call and the json call.

makermelissa commented 4 years ago

That's fine. It was a clear enough message that I figured it out pretty quickly. I would have probably released it as 2.0.0 though. :)

tannewt commented 4 years ago

@makermelissa Ya, fair. I was trying my best to be backwards compatible and maybe I was too optimistic. :-)

makermelissa commented 4 years ago

No problem. I have updated the Portal libraries and am unaware of any others this change affects, so closing.