Skip to content

unix/modsocket: Add "sendall" method to socket class. #17369

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agatti
Copy link
Contributor

@agatti agatti commented May 27, 2025

Summary

This PR adds an implementation for "socket.sendall" to the Unix port.

Right now the implementation is a wrapper over a single "socket.send" call, since it wasn't possible to let "socket.send" perform a partial transfer. With no partial transfers it is not possible to have a testable implementation following the expected behaviour, so a single send operation is done and OSErr(EINTR) is raised if a partial transfer occurs.

The discussion for the issue linked to this PR contains more information about the efforts made to let partial transfers happen.

This fixes #16803.

Testing

A new test is introduced to exercise socket.sendall, called tests/multi_net/tcp_sendall.py. This could have been folded into tests/multi_net/tcp_data.py, but the Zephyr port doesn't have a socket.sendall implementation.

Trade-offs and Alternatives

There's a modest size increase. The footprint increase could have been smaller if socket.sendall was aliased to socket.send like the CC3200 port does, but then the behaviour would be slightly incompatible with CPython (socket.sendall is supposed to return None, not the sent bytes count).

This commit adds an implementation for "socket.sendall" to the Unix
port.

Right now the implementation is a wrapper over a single "socket.send"
call, since it wasn't possible to let "socket.send" perform a partial
transfer.  With no partial transfers it is not possible to have a
testable implementation following the expected behaviour, so a single
send operation is done and OSErr(EINTR) is raised if a partial transfer
occurs.

The discussion for the issue linked to this PR contains more information
about the efforts made to let partial transfers happen.

This fixes micropython#16803.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (49f81d5) to head (25ca8c9).
Report is 83 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17369   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21898    21898           
=======================================
  Hits        21579    21579           
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:  +400 +0.047% standard[incl +32(data)]
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UNIX build missing socket.sendall() method
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy