mirror of
https://github.com/python/cpython.git
synced 2025-11-11 02:52:04 +00:00
[3.13] gh-136234: Fix SelectorSocketTransport.writelines to be robust to connection loss (GH-136743) (GH-138702) (#139710)
[3.14] gh-136234: Fix `SelectorSocketTransport.writelines` to be robust to connection loss (GH-136743) (GH-138702)
(cherry picked from commit 5cd6cfe4cf)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
333d4a6f49
commit
060eef27c3
3 changed files with 25 additions and 0 deletions
|
|
@ -1170,6 +1170,13 @@ def writelines(self, list_of_data):
|
|||
raise RuntimeError('unable to writelines; sendfile is in progress')
|
||||
if not list_of_data:
|
||||
return
|
||||
|
||||
if self._conn_lost:
|
||||
if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
|
||||
logger.warning('socket.send() raised exception.')
|
||||
self._conn_lost += 1
|
||||
return
|
||||
|
||||
self._buffer.extend([memoryview(data) for data in list_of_data])
|
||||
self._write_ready()
|
||||
# If the entire buffer couldn't be written, register a write handler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue