classification
Title: asyncio open_connection fails when a socket is explicitly closed
Type: Stage:
Components: asyncio, Windows Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, danielen1337, eamanu, paul.moore, steve.dower, tim.golden, yselivanov, zach.ware
Priority: normal Keywords:

Created on 2021-02-18 13:46 by danielen1337, last changed 2021-02-18 16:06 by eamanu.

Messages (3)
msg387228 - (view) Author: Daniel Engel (danielen1337) Date: 2021-02-18 13:46
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import socket
   ...: s1, s2 = socket.socketpair()
   ...: import asyncio
   ...: async def test():
   ...:     r1, w1 = await asyncio.open_connection(sock=s1)
   ...:     r2, w2 = await asyncio.open_connection(sock=s2)
   ...:     s1.close()
   ...: asyncio.run(test())
Exception in callback _ProactorBasePipeTransport._call_connection_lost(ConnectionAbo...e, 1236, None))
handle: <Handle _ProactorBasePipeTransport._call_connection_lost(ConnectionAbo...e, 1236, None))>
Traceback (most recent call last):
  File "c:\python39\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "c:\python39\lib\asyncio\proactor_events.py", line 162, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
msg387235 - (view) Author: Emmanuel Arias (eamanu) * Date: 2021-02-18 14:37
I cannot reproduce on a Debian machine. Seems to be a Windows component issue?
msg387238 - (view) Author: Daniel Engel (danielen1337) Date: 2021-02-18 15:07
It reproduced on a windows machine
History
Date User Action Args
2021-02-18 16:06:00eamanusetnosy: + paul.moore, tim.golden, zach.ware, steve.dower
components: + Windows
2021-02-18 15:07:47danielen1337setmessages: + msg387238
2021-02-18 14:37:11eamanusetnosy: + eamanu
messages: + msg387235
2021-02-18 13:46:25danielen1337create