summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-02-18 11:01:32 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-02-18 11:01:32 (GMT)
commita2b64e630e54027b5f49bf9f6cbdd4efb51aba4e (patch)
treedfa384ea60a4cb3884546dbeda995e8d8978b744 /Lib
parentbd8112901ae442413c77c8cf2f4ae42f6905565d (diff)
parentc12fef9aa3282144dba83e0cd543bb510de6a745 (diff)
downloadcpython-a2b64e630e54027b5f49bf9f6cbdd4efb51aba4e.zip
cpython-a2b64e630e54027b5f49bf9f6cbdd4efb51aba4e.tar.gz
cpython-a2b64e630e54027b5f49bf9f6cbdd4efb51aba4e.tar.bz2
Issue #26309: Merge socketserver fix from 3.5
Diffstat (limited to 'Lib')
-rw-r--r--Lib/socketserver.py2
-rw-r--r--Lib/test/test_socketserver.py24
2 files changed, 26 insertions, 0 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index e16aca5..1524d16 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -319,6 +319,8 @@ class BaseServer:
except:
self.handle_error(request, client_address)
self.shutdown_request(request)
+ else:
+ self.shutdown_request(request)
def handle_timeout(self):
"""Called if no new request arrives within self.timeout.
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 1ea66a6..f8f7762 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -280,6 +280,30 @@ class SocketServerTest(unittest.TestCase):
socketserver.TCPServer((HOST, -1),
socketserver.StreamRequestHandler)
+ def test_shutdown_request_called_if_verify_request_false(self):
+ # Issue #26309: BaseServer should call shutdown_request even if
+ # verify_request is False
+ shutdown_called = False
+
+ class MyServer(socketserver.TCPServer):
+ def verify_request(self, request, client_address):
+ return False
+
+ def shutdown_request(self, request):
+ nonlocal shutdown_called
+ shutdown_called = True
+ super().shutdown_request(request)
+
+ def connect_to_server(proto, addr):
+ s = socket.socket(proto, socket.SOCK_STREAM)
+ s.connect(addr)
+ s.close()
+
+ self.run_server(MyServer,
+ socketserver.StreamRequestHandler,
+ connect_to_server)
+ self.assertEqual(shutdown_called, True)
+
class MiscTestCase(unittest.TestCase):