Skip to content

Intermittent ValueError on first GET response with ESP32-S2 #55

Closed
@anecdata

Description

@anecdata

This has been observed for some months over successive versions of circuitpython and Requests (first noted in a comment in #34 ), current example with:

FeatherS2 with ESP32S2
6.1.0-beta.2-5-gacbc5fc7a on 2020-12-06
adafruit-circuitpython-bundle-6.x-mpy-20201205

The first GET in code.py will sometimes result in this exception:

Traceback (most recent call last):
  File "code.py", line 522, in http_get
  File "adafruit_requests.py", line 343, in text
  File "adafruit_requests.py", line 332, in content
  File "adafruit_requests.py", line 378, in iter_content
  File "adafruit_requests.py", line 237, in _readinto
ValueError: invalid syntax for integer with base 16

Subsequent tries at GET always yield:

Traceback (most recent call last):
  File "code.py", line 512, in http_get
  File "adafruit_requests.py", line 612, in get
  File "adafruit_requests.py", line 568, in request
  File "adafruit_requests.py", line 277, in close
  File "adafruit_requests.py", line 199, in _readto
  File "adafruit_requests.py", line 143, in _recv_into
OSError: [Errno 9] EBADF

and reload is the only thing that seems to fix it.

I think it happens when the response is empty or times out or some similar situation. The response status_code, reason, headers, and text are all empty at the time the exception is raised. The server side sees 200 status code and non-zero content length sent to client.

I see this on chunked responses, but I'm not sure if that's relevant, it's just mostly all I ever do.

This has no effect on correcting the issue:

    wifi.radio.enabled = False
    wifi.radio.enabled = True

Once Requests reloads normally and works on the first GET, it will continue to run fine for a time, then the OSError: [Errno 9] EBADF may crop up again later, requiring a reload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions