[issue39797] shutdown() in socketserver.BaseServer should be in a different thread from serve_forever()

New submission from Ama Aje My Fren <amaajemyfren@gmail.com>: When a subclass of socketserver.BaseServer is running after calling serve_forever() and needs to be shutdown, it may be shut down by sending a [shutdown()](https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer....). The thing is though that the shutdown() call must be run in a different thread than the one where the serve_forever() was called otherwise it will deadlock. This is documented in the [code](https://github.com/python/cpython/blob/3.8/Lib/socketserver.py#L244) but not in the documentation. It should be in the documentation as well as it is not obvious. ---------- assignee: docs@python components: Documentation messages: 362981 nosy: amaajemyfren, docs@python priority: normal severity: normal status: open title: shutdown() in socketserver.BaseServer should be in a different thread from serve_forever() type: enhancement versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by Ama Aje My Fren <amaajemyfren@gmail.com>: ---------- keywords: +patch pull_requests: +18278 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18926 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by Ama Aje My Fren <amaajemyfren@gmail.com>: ---------- pull_requests: +18281 pull_request: https://github.com/python/cpython/pull/18929 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by Ama Aje My Fren <amaajemyfren@gmail.com>: ---------- pull_requests: +18282 pull_request: https://github.com/python/cpython/pull/18930 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by Ama Aje My Fren <amaajemyfren@gmail.com>: ---------- pull_requests: +18284 pull_request: https://github.com/python/cpython/pull/18932 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by Ama Aje My Fren <amaajemyfren@gmail.com>: ---------- pull_requests: +18285 pull_request: https://github.com/python/cpython/pull/18933 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 2de7ac97981c30e9c1001b05a771f52a41772c54 by amaajemyfren in branch 'master': bpo-39797 Changes to socketserver.BaseServer's shutdown() method. (GH-18929) https://github.com/python/cpython/commit/2de7ac97981c30e9c1001b05a771f52a417... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +18445 pull_request: https://github.com/python/cpython/pull/19085 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +18446 pull_request: https://github.com/python/cpython/pull/19086 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 64937d308c71a5c95627b0a0d0574d164c0cf30a by Miss Islington (bot) in branch '3.7': bpo-39797 Changes to socketserver.BaseServer's shutdown() method. (GH-18929) https://github.com/python/cpython/commit/64937d308c71a5c95627b0a0d0574d164c0... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 29723368e797f36ba8940f25b6e677852b7313b2 by Miss Islington (bot) in branch '3.8': bpo-39797 Changes to socketserver.BaseServer's shutdown() method. (GH-18929) https://github.com/python/cpython/commit/29723368e797f36ba8940f25b6e677852b7... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________

Ned Deily <nad@python.org> added the comment: Thank you for your PR! ---------- nosy: +ned.deily resolution: -> fixed stage: patch review -> resolved status: open -> closed type: enhancement -> versions: -Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39797> _______________________________________
participants (3)
-
Ama Aje My Fren
-
miss-islington
-
Ned Deily