classification
Title: asyncio ProactorEventLoop: wait_closed() can raise ConnectionResetError
Type: Stage: patch review
Components: asyncio, Windows Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: asvetlov Nosy List: aeros, asvetlov, lukasz.langa, paul.moore, steve.dower, tim.golden, vstinner, yselivanov, zach.ware
Priority: high Keywords: patch

Created on 2019-11-19 22:06 by yselivanov, last changed 2020-02-25 12:03 by lukasz.langa.

Pull Requests
URL Status Linked Edit
PR 18199 open aeros, 2020-01-27 08:40
Messages (6)
msg356996 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-11-19 22:06
The exception should probably be just ignored.  Andrew, thoughts?

Here's an example error traceback:

      Traceback (most recent call last):
        File "c:\projects\asyncpg\asyncpg\connection.py", line 1227, in _cancel
          await w.wait_closed()
        File "C:\Python38\lib\asyncio\streams.py", line 376, in wait_closed
          await self._protocol._get_close_waiter(self)
        File "c:\projects\asyncpg\asyncpg\connection.py", line 1202, in _cancel
          await r.read()  # Wait until EOF
        File "C:\Python38\lib\asyncio\streams.py", line 694, in read
          block = await self.read(self._limit)
        File "C:\Python38\lib\asyncio\streams.py", line 701, in read
          await self._wait_for_data('read')
        File "C:\Python38\lib\asyncio\streams.py", line 534, in _wait_for_data
          await self._waiter
        File "C:\Python38\lib\asyncio\proactor_events.py", line 280, in _loop_reading
          data = fut.result()
        File "C:\Python38\lib\asyncio\windows_events.py", line 808, in _poll
          value = callback(transferred, key, ov)
        File "C:\Python38\lib\asyncio\windows_events.py", line 457, in finish_recv
          raise ConnectionResetError(*exc.args)
      ConnectionResetError: [WinError 64] The specified network name is no longer available
msg358097 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2019-12-09 14:18
Note: this is going to miss Python 3.8.1 as I'm releasing 3.8.1rc1 right now.  Please address this before 3.8.2 (due in February).
msg358109 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-12-09 15:01
Sorry, I've missed this issue.
I'll address it in a while.
msg360410 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-21 17:23
Why is this issue marked as a release blocker? Is it a Python 3.8 regression, or just a regular bug?
msg360742 - (view) Author: Kyle Stanley (aeros) * (Python triager) Date: 2020-01-27 08:22
> The exception should probably be just ignored.

It looks like the "ERROR_NETNAME_DELETED" (win32 error 64) exception is already ignored in multiprocessing's connection.wait(): https://github.com/python/cpython/blob/bccacd19fa7b56dcf2fbfab15992b6b94ab6666b/Lib/multiprocessing/connection.py#L857. Would it be appropriate to ignore it here as well?

I think that we should still retain the ConnectionResetError for "ERROR_OPERATION_ABORTED", but just specifically ignore "ERROR_NETNAME_DELETED". Ignoring "ERROR_OPERATION_ABORTED" doesn't seem correct here since it's relied on for cancelling file I/O (see https://docs.microsoft.com/en-us/windows/win32/fileio/canceling-pending-i-o-operations).

The patch should be straightforward. I'll test it locally and then open a PR, unless Andrew is currently working on it.
msg362633 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-02-25 12:03
Downgrading priority on this, agreed with Victor.
History
Date User Action Args
2020-02-25 12:03:54lukasz.langasetpriority: release blocker -> high

messages: + msg362633
2020-01-27 08:40:14aerossetkeywords: + patch
stage: patch review
pull_requests: + pull_request17577
2020-01-27 08:22:16aerossetnosy: + aeros
messages: + msg360742
2020-01-21 17:25:24vstinnersetnosy: + paul.moore, tim.golden, zach.ware, steve.dower
components: + Windows, asyncio
2020-01-21 17:25:08vstinnersettitle: wait_closed() can raise ConnectionResetError -> asyncio ProactorEventLoop: wait_closed() can raise ConnectionResetError
2020-01-21 17:23:34vstinnersetnosy: + vstinner
messages: + msg360410
2019-12-09 15:01:41asvetlovsetassignee: asvetlov
2019-12-09 15:01:32asvetlovsetmessages: + msg358109
2019-12-09 14:18:37lukasz.langasetmessages: + msg358097
2019-11-19 22:06:26yselivanovcreate