From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 27 Oct 2022 03:03:58 +0000 (-0700) Subject: gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times... X-Git-Tag: v3.10.9~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb80f6ad92f6765cdcd9c887c389ea37103e6902;p=thirdparty%2FPython%2Fcpython.git gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times (GH-98704) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> (cherry picked from commit 8a755423eba8e19704d96905730cf7f50083eb23) Co-authored-by: Ken Jin --- diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 610d67387d12..0916d9eb5706 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -152,6 +152,8 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, 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: diff --git a/Misc/NEWS.d/next/Library/2022-10-26-07-51-55.gh-issue-98703.0hW773.rst b/Misc/NEWS.d/next/Library/2022-10-26-07-51-55.gh-issue-98703.0hW773.rst new file mode 100644 index 000000000000..3107519a8714 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-10-26-07-51-55.gh-issue-98703.0hW773.rst @@ -0,0 +1,2 @@ +Fix :meth:`asyncio.StreamWriter.drain` to call ``protocol.connection_lost`` +callback only once on Windows.