Kaydet (Commit) 6f97a50c authored tarafından Denis Ledoux's avatar Denis Ledoux Kaydeden (comit) Victor Stinner

bpo-35017, socketserver: don't accept request after shutdown (GH-9952) (GH-10129)

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.

(cherry picked from commit 10cb3760)
üst 9dcb517f
......@@ -229,6 +229,9 @@ class BaseServer:
# shutdown request and wastes cpu at all other times.
r, w, e = _eintr_retry(select.select, [self], [], [],
poll_interval)
# bpo-35017: shutdown() called during select(), exit immediately.
if self.__shutdown_request:
break
if self in r:
self._handle_request_noblock()
finally:
......
: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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment