[issue30861] StreamReader does not return reamaing and ready data buffer before raise the Exeption

pfreixes report at bugs.python.org
Thu Jul 6 17:04:22 EDT 2017


pfreixes added the comment:

As was said, the assumption here is the data that came to the buffer must be available.

For example, the next snippet shows a Redis client that expects the data message plus the RST packet, where the redis-server was configured to accept max N connections, the connection used by this snippet was the N+1

import socket
import time

s = socket.socket(
    socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 6379))

# give enought time to get the
# data plus the RST Package
time.sleep(1)

# read the data
print(s.recv(100))

It works like a charm.

IMHO this is not a matter of RST vs close graceful, its a matter of giving always the chance to the developer to read the data that is still remaining and ready into the buffer.

The current implementation is in somehow not predictable. Different network latencies with the same scenario can produce different outputs and the same with how the read of the Streamer is handled by the developer.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30861>
_______________________________________


More information about the Python-bugs-list mailing list