[New-bugs-announce] [issue25441] StreamWriter.drain() unreliably reports closed sockets

Sebastien Bourdeauducq report at bugs.python.org
Mon Oct 19 16:12:10 CEST 2015


New submission from Sebastien Bourdeauducq:

1. Open a listening socket:
$ nc6 -l -p 1066

2. Run the following (tested here on Linux):
import asyncio

async def bug():
    reader, writer = await asyncio.open_connection("::1", "1066")
    while True:
        writer.write("foo\n".encode())
        await writer.drain()
        # Uncommenting this makes drain() raise BrokenPipeError
        # when the server closes the connection.
        #await asyncio.sleep(0.1)

loop = asyncio.get_event_loop()
loop.run_until_complete(bug())

3. Terminate netcat with Ctrl-C. The program will go on a endless loop of "socket.send() raised exception." as writer.drain() fails to raise an exception to report the closed connection. Reducing the output rate of the program by using asyncio.sleep causes writer.drain() to raise BrokenPipeError (and shouldn't it be ConnectionResetError?)

----------
components: asyncio
messages: 253181
nosy: gvanrossum, haypo, sebastien.bourdeauducq, yselivanov
priority: normal
severity: normal
status: open
title: StreamWriter.drain() unreliably reports closed sockets
versions: Python 3.5

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


More information about the New-bugs-announce mailing list