New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32S2 time.sleep(60) fails but time.sleep(15) works #4061
Comments
I don't think this is a sleep issue. I think it has to do with @hierophect's socket changes changing the exception when a socket times out and closes. By increasing the sleep, you are giving the socket time to close. I suspect the fix is to make requests catch the error, not to change CircuitPython, because I know @hierophect did a bunch of work comparing the failure modes with CPython. |
@anecdata @tannewt I'm going to track the ENOTCONN problems in this thread since it's for Circuitpython as opposed to Requests which I'm not as familiar with. Currently ENOTCONN is thrown during failed send() calls, which is not the right application of that error. I'm not sure what to replace it with yet, Cpython isn't super clear on that front. Is the failure of some send() calls a normal part of this application? If too many are failing, it might be the result of some of the non-blocking changes causing |
|
I've been working on this more in my #4049 PR build. Here are the results I get, with extra debug information added from the C level:
Successful sends are spaced out, but when failures occur, they happen in a constant stream with no delays. There are a couple things I find confusing about this.
|
I can also confirm none of this happens with time.sleep(15) either - it just uses socket 60 happily over and over with no failures or new sockets created. |
I think this might actually be a Requests library error after all? Does this line seem like it could be a potential socket leak? The debug output suggests that sockets are not being closed properly - I think what's happening here is that the first call creates a new socket, then the second one tries to re-use that socket and fails, but doesn't close it. I still don't know why the sockets are incrementing by 2 internally, though... |
This turned out to be a 4(!) part issue:
I still don't know if any of this is related to adafruit/Adafruit_CircuitPython_Requests#63. @anecdata you could try out some of these changes and see if they help with your problem. For Circuitpython, the changes that need to happen are the fix to |
I may be recalling wrong, but I thought default |
@anecdata I think you're right, but I wasn't the one who lowered the max so I don't know how much of a memory drag it is. |
@jerryneedell can you retest this and see if it works for you now? My personal test works. |
Two issues I'm encountering post-4049:
Addendum: |
@anecdata I'm looking into the HTTP thing now, sorry for the delay, I've been having power cutouts from the weather. As for the second point, are we sure that isn't defined behavior? I'm not an SSL expert but can an SSL session just persist indefinitely? |
The |
@hierophect I just tried with tip of main and it still fails with time.sleep(60)-- do I need pull in a PR or update any libraries? |
@jerryneedell you'd need to go into Requests and search for |
@hierophect That appears to have fixed it for my initial example -- made it through 3 cycles so far |
Is this change being incorporated into Requests? |
I'll submit a PR |
I'm closing this issue now as @jerryneedell's remaining issue is in the Requests library and is continued in this issue: adafruit/Adafruit_CircuitPython_Requests#67 |
May be related to adafruit/Adafruit_CircuitPython_Requests#63
On a SAOLA WROVER
If I run the code below with time.sleep(15) it executes normally
but with time.sleep(60)
it executes normally for the first pass
throws and error ENOTCONN on the second pass but recovers
then fails on the thirds and subsequent passes
Am I doing something wrong?
has time.sleep() changed?
here is the code
The text was updated successfully, but these errors were encountered: