Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue25441

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:StreamWriter.drain() unreliably reports closed sockets
Type:Stage:
Components:asyncioVersions:Python 3.6, Python 3.4, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: gvanrossumNosy List: gvanrossum, python-dev, sebastien.bourdeauducq, vstinner, yselivanov
Priority:normalKeywords:

Created on2015-10-19 14:12 bysebastien.bourdeauducq, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Messages (5)
msg253181 -(view)Author: Sebastien Bourdeauducq (sebastien.bourdeauducq)*Date: 2015-10-19 14:12
1. Open a listening socket:$ nc6 -l -p 10662. Run the following (tested here on Linux):import asyncioasync 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?)
msg253182 -(view)Author: Guido van Rossum (gvanrossum)*(Python committer)Date: 2015-10-19 14:46
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.)
msg253184 -(view)Author: Sebastien Bourdeauducq (sebastien.bourdeauducq)*Date: 2015-10-19 16:19
Yes, this patch fixes the problem (in both this example and my real application). Thanks!
msg253186 -(view)Author: Guido van Rossum (gvanrossum)*(Python committer)Date: 2015-10-19 19:02
Fixed by17f76258d11d,d30fbc55194d and08adb4056b5f.
msg253187 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-10-19 19:10
New changeset17f76258d11d 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/17f76258d11dNew changesetd30fbc55194d 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/d30fbc55194dNew changeset08adb4056b5f 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
History
DateUserActionArgs
2022-04-11 14:58:22adminsetgithub: 69627
2015-10-19 19:10:21python-devsetnosy: +python-dev
messages: +msg253187
2015-10-19 19:02:16gvanrossumsetstatus: open -> closed
assignee:gvanrossum
resolution: fixed
messages: +msg253186
2015-10-19 16:19:53sebastien.bourdeauducqsetmessages: +msg253184
2015-10-19 14:47:14gvanrossumsetversions: + Python 3.4, Python 3.6
2015-10-19 14:46:57gvanrossumsetmessages: +msg253182
2015-10-19 14:12:10sebastien.bourdeauducqcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp