]> 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:04:43 +0000 (20:04 -0700)
committerGitHub <noreply@github.com>
Thu, 27 Oct 2022 03:04:43 +0000 (20:04 -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 2685a3376cfd9562ae53721628763729db3c673a..c6aab408fc74107c29d99c3fca0272c143d68cf7 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.