[issue25441] StreamWriter.drain() unreliably reports closed sockets

2015-10-19 Thread Sebastien Bourdeauducq

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25441] StreamWriter.drain() unreliably reports closed sockets

2015-10-19 Thread Guido van Rossum

Guido van Rossum added the comment:

See also this upstream git issue: https://github.com/python/asyncio/issues/263. 
Let me know whether the patch suggested there works for you, and I'll 
prioritize getting it checked in. (Help would also be appreciated, e.g. in the 
form of a unittest.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25441] StreamWriter.drain() unreliably reports closed sockets

2015-10-19 Thread Guido van Rossum

Changes by Guido van Rossum :


--
versions: +Python 3.4, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25441] StreamWriter.drain() unreliably reports closed sockets

2015-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 17f76258d11d by Guido van Rossum in branch '3.4':
Issue #25441: asyncio: Raise error from drain() when socket is closed.
https://hg.python.org/cpython/rev/17f76258d11d

New changeset d30fbc55194d by Guido van Rossum in branch '3.5':
Issue #25441: asyncio: Raise error from drain() when socket is closed. (Merge 
3.4->3.5)
https://hg.python.org/cpython/rev/d30fbc55194d

New changeset 08adb4056b5f by Guido van Rossum in branch 'default':
Issue #25441: asyncio: Raise error from drain() when socket is closed. (Merge 
3.5->3.6)
https://hg.python.org/cpython/rev/08adb4056b5f

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25441] StreamWriter.drain() unreliably reports closed sockets

2015-10-19 Thread Guido van Rossum

Guido van Rossum added the comment:

Fixed by 17f76258d11d, d30fbc55194d and 08adb4056b5f.

--
assignee:  -> gvanrossum
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25441] StreamWriter.drain() unreliably reports closed sockets

2015-10-19 Thread Sebastien Bourdeauducq

Sebastien Bourdeauducq added the comment:

Yes, this patch fixes the problem (in both this example and my real 
application). Thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com