Title: os.writev and socket.sendmsg return value are not ideal
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, tzickel
Priority: normal Keywords:

Created on 2020-03-20 07:39 by tzickel, last changed 2020-03-20 07:39 by tzickel.

Messages (1)
msg364651 - (view) Author: (tzickel) * Date: 2020-03-20 07:39
os.writev and socket.sendmsg accept an iterable but the return value is number of bytes sent. That is not helpful as the user will have to write manual code to figure out which part of the iterable was not sent.

I propose to make a version of the functions where:

1. The return value is an iterable of the leftovers (including a maybe one-time memoryview into an item who has been partly-sent).

2. There is a small quirk where writev accepts only sequences but sendmsg accepts any iterable, which causes them not to behave the same for no good reason.

3. Do we want an sendmsgall like sendall in socket, where it doesn't give up until everything is sent ?

4. Today trying to use writev / sendmsg to be fully complaint requires checking the number of input items in the iterable to not go over IOV_MAX, maybe the python version of the functions should handle this automatically (and if it overflows, return the extra in leftovers) ?

Should the functions be the current one with an optional argument (return_leftovers) or a new function altogether.
Date User Action Args
2020-03-20 07:39:00tzickelcreate