]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 27 Oct 2022 03:03:58 +0000 (20:03 -0700)
committerGitHub <noreply@github.com>
Thu, 27 Oct 2022 03:03:58 +0000 (20:03 -0700)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
(cherry picked from commit 8a755423eba8e19704d96905730cf7f50083eb23)

Co-authored-by: Ken Jin <kenjin@python.org>
Lib/asyncio/proactor_events.py
Misc/NEWS.d/next/Library/2022-10-26-07-51-55.gh-issue-98703.0hW773.rst [new file with mode: 0644]

index 610d67387d12844e08b612915135bd298f0b4c4e..0916d9eb5706ca48b2165e30a0f1c409cabc60b8 100644 (file)
@@ -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 (file)
index 0000000..3107519
--- /dev/null
@@ -0,0 +1,2 @@
+Fix :meth:`asyncio.StreamWriter.drain` to call ``protocol.connection_lost``
+callback only once on Windows.