summaryrefslogtreecommitdiffstats
path: root/Lib/socketserver.py
diff options
context:
space:
mode:
authorDenis Ledoux <be.ledoux.denis@gmail.com>2018-10-26 13:46:17 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-10-26 13:46:17 (GMT)
commit10cb3760e8631a27f5db1e51b05494e29306c671 (patch)
tree659467c2c67072a1e6b83bc0d994f47ed8b727f3 /Lib/socketserver.py
parent25a525bf5a9c630a992d2048d863841481004465 (diff)
downloadcpython-10cb3760e8631a27f5db1e51b05494e29306c671.zip
cpython-10cb3760e8631a27f5db1e51b05494e29306c671.tar.gz
cpython-10cb3760e8631a27f5db1e51b05494e29306c671.tar.bz2
bpo-35017, socketserver: don't accept request after shutdown (GH-9952)
Prior to this revision, after the shutdown of a `BaseServer`, the server accepted a last single request if it was sent between the server socket polling and the polling timeout. This can be problematic for instance for a server restart for which you do not want to interrupt the service, by not closing the listening socket during the restart. One request failed because of this behavior. Note that only one request failed, following requests were not accepted, as expected.
Diffstat (limited to 'Lib/socketserver.py')
-rw-r--r--Lib/socketserver.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 9dfd21b..f037791 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -230,6 +230,9 @@ class BaseServer:
while not self.__shutdown_request:
ready = selector.select(poll_interval)
+ # bpo-35017: shutdown() called during select(), exit immediately.
+ if self.__shutdown_request:
+ break
if ready:
self._handle_request_noblock()