Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions by Kumar
Co-Authored-By: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
Fidget-Spinner and kumaraditya303 committed Oct 26, 2022
commit 26dfd856525cdd9cb6274afe07a48d70f799bac0
8 changes: 2 additions & 6 deletions Lib/asyncio/proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def __init__(self, loop, sock, protocol, waiter=None,
super().__init__(extra, loop)
self._set_extra(sock)
self._sock = sock
self._sock_called_close = False
self.set_protocol(protocol)
self._server = server
self._buffer = None # None or bytearray.
Expand Down Expand Up @@ -153,6 +152,8 @@ def _force_close(self, exc):
self._loop.call_soon(self._call_connection_lost, exc)

def _call_connection_lost(self, exc):
if self._called_connection_lost:
return
try:
self._protocol.connection_lost(exc)
finally:
Expand All @@ -162,12 +163,7 @@ def _call_connection_lost(self, exc):
# cure it, but maybe using DisconnectEx() would be better.
if hasattr(self._sock, 'shutdown') and self._sock.fileno() != -1:
self._sock.shutdown(socket.SHUT_RDWR)
Comment thread
Fidget-Spinner marked this conversation as resolved.
# We can't call sock._close() indiscriminately because something
# else might be calling _call_connection_lost again.
if not self._sock_called_close:
self._sock.close()
self._sock = None
self._sock_called_close = True
server = self._server
if server is not None:
server._detach()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Fix asyncio ``drain`` closing a non-existent socket multiple times.
Fix :meth:`asyncio.StreamWriter.drain` to call ``protocol.connection_lost``
callback only once on Windows.