[New-bugs-announce] [issue40023] os.writev and socket.sendmsg return value are not ideal

tzickel report at bugs.python.org
Fri Mar 20 03:39:00 EDT 2020


New submission from tzickel <icebreak at yahoo.com>:

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.

----------
components: Library (Lib)
messages: 364651
nosy: larry, tzickel
priority: normal
severity: normal
status: open
title: os.writev and socket.sendmsg return value are not ideal
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40023>
_______________________________________


More information about the New-bugs-announce mailing list