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

Skip to content

Commit 36852b7

Browse files
author
Kristján Valur Jónsson
committed
Issue #14574: Ignore socket errors raised when flushing a connection on close.
1 parent 303eb47 commit 36852b7

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
@@ -299,8 +299,8 @@ request.
299299
.. method:: RequestHandler.finish()
300300

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

305305

306306
.. method:: RequestHandler.handle()

Lib/socketserver.py

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

701701
def finish(self):
702702
if not self.wfile.closed:
703-
self.wfile.flush()
703+
try:
704+
self.wfile.flush()
705+
except socket.error:
706+
# An final socket error may have occurred here, such as
707+
# the local error ECONNABORTED.
708+
pass
704709
self.wfile.close()
705710
self.rfile.close()
706711

0 commit comments

Comments
 (0)