mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
25a525bf5a
commit
10cb3760e8
2 changed files with 6 additions and 0 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
:meth:`socketserver.BaseServer.serve_forever` now exits immediately if it's
|
||||
:meth:`~socketserver.BaseServer.shutdown` method is called while it is
|
||||
polling for new events.
|
Loading…
Add table
Add a link
Reference in a new issue