Skip to content

Check for send to return 0 #36

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

Merged
merged 5 commits into from
Sep 24, 2020
Merged

Check for send to return 0 #36

merged 5 commits into from
Sep 24, 2020

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Sep 23, 2020

When it does, close the socket and raise an Exception. This
prevents leaking sockets when send fails.

When it does, close the socket and raise an Exception. This
prevents leaking sockets when send fails.
@tannewt tannewt requested a review from brentru September 23, 2020 22:56
Copy link
Member

@brentru brentru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannewt LGTM, tested OK on all CPython examples.

Only thing that I noticed is the code catches an exception raised by _send and closes the socket within _send_request. Any function relying on _send will need to implement this try/except or the socket won't be closed.

Could you instead close the socket within _send when sent returns 0?

@tannewt
Copy link
Member Author

tannewt commented Sep 24, 2020

Thanks @brentru. I didn't put it there because I want to remove _send eventually when the send implementation of our sockets is consistent.

I believe ESP32SPI's send works like CPython's sendall at the moment because it will raise it's own RuntimeError when unable to send everything. CPython's send won't raise an error, just return 0.

@tannewt tannewt merged commit 46007a6 into adafruit:master Sep 24, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Sep 25, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_FONA to 2.1.0 from 2.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_FONA#7 from brentru/update-property-docstrings

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.7.2 from 1.7.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#36 from tannewt/check_send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants