Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8e7e2b

Browse files
author
Kristján Valur Jónsson
committed
Merge with 3.2 :
Issue #14574: Ignore socket errors raised when flushing a connection on close.
2 parents 00679a7 + 36852b7 commit c8e7e2b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

Doc/library/socketserver.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ request.
313313
.. method:: RequestHandler.finish()
314314

315315
Called after the :meth:`handle` method to perform any clean-up actions
316-
required. The default implementation does nothing. If :meth:`setup` or
317-
:meth:`handle` raise an exception, this function will not be called.
316+
required. The default implementation does nothing. If :meth:`setup`
317+
raises an exception, this function will not be called.
318318

319319

320320
.. method:: RequestHandler.handle()

Lib/socketserver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,12 @@ def setup(self):
718718

719719
def finish(self):
720720
if not self.wfile.closed:
721-
self.wfile.flush()
721+
try:
722+
self.wfile.flush()
723+
except socket.error:
724+
# An final socket error may have occurred here, such as
725+
# the local error ECONNABORTED.
726+
pass
722727
self.wfile.close()
723728
self.rfile.close()
724729

0 commit comments

Comments
 (0)