Closed hierophect closed 3 years ago
I fixed this for my example program by simply replacing except _sendFailed:
with except:
but I don't know if there's issues with that?
Ya, don't do except:
because you'll catch absolutely everything. You can add a second except for the error type of "Failed SSL handshake" though.
@tannewt what's the issue with catching everything here? Is there an exception that's considered acceptable? All the step does is mark that the socket is not ready to receive data and close it, which seems like the right thing to do for any exception.
Alternatively I could add in an else:
to actually raise exceptions that aren't of the two specified types.
@tannewt what's the issue with catching everything here? Is there an exception that's considered acceptable? All the step does is mark that the socket is not ready to receive data and close it, which seems like the right thing to do for any exception.
Catching everything is bad because you'll catch extra stuff. Reload, keyboard and deep sleep all use exceptions. Those things (or others) may be caught higher and the code will expect the socket to continue. So, always be explicit with catching exceptions.
Closed by #70
In the request method, while attempting to send a request, only
_SendFailed
exceptions are caught and all others (such as aFailed SSL handshake
, which may occur after too much time has elapsed between requests) are ignored. This then leads torecv
orrecv_into
being run on an invalid connection, resulting in an exception and potentially a socket leak.This was discovered while debugging adafruit/circuitpython#4061, but does not wholly fix the issue as the code will then run into issue #66. May be related to #63.