[Patches] [ python-Patches-1103213 ] Adding the missing
socket.recvall() method
SourceForge.net
noreply at sourceforge.net
Thu Feb 24 21:55:05 CET 2005
Patches item #1103213, was opened at 2005-01-16 05:02
Message generated for change (Comment added) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1103213&group_id=5470
Category: Modules
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Irmen de Jong (irmen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Adding the missing socket.recvall() method
Initial Comment:
This patch is a first take at adding a recvall method
to the socket object, to mirror the existence of the
sendall method.
If the MSG_WAITALL flag is available, the recvall
method just calls recv() with that flag.
If it is not available, it uses an internal loop
(during the loop, threads are allowed, so this improves
concurrency).
Having this method makes Python code much simpler;
before you had to test for MSG_WAITALL yourself and
write your own loop in Python if the flag is not there
(on Windows for instance).
(also, having the loop in C improves performance and
concurrency compared to the same loop in Python)
Note: the patch hasn't been tested very well yet.
(code is based on a separate extension module found
here: http://www.it-ernst.de/python/ )
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2005-02-24 21:55
Message:
Logged In: YES
user_id=21627
I like the feature (but see below). The patch is incomplete,
though:
- there are no changes to Doc/lib/libsocket.tex
- there are no changes to Lib/test/test_socket.py
Furthermore, the patch is also wrong: if a later recv call
fails, all data read so far are discarded. I believe this is
different from the WAITALL flag, which I hope will preserve
the data in the socket, for a subsequent recv call. As
keeping the data in the socket seems unimplementable, the
partial data should somehow be returned to the application.
A note on coding style: please omit the spaces after the
opening paren and before the closing in
while ( (bytes_got<total_size) && (n > 0) )
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1103213&group_id=5470
More information about the Patches
mailing list