Skip to content

bpo-43867: multiprocessing Server catchs SystemExit #25441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Lib/multiprocessing/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,8 @@ def accepter(self):
t.daemon = True
t.start()

def handle_request(self, c):
'''
Handle a new connection
'''
funcname = result = request = None
def _handle_request(self, c):
request = None
try:
connection.deliver_challenge(c, self.authkey)
connection.answer_challenge(c, self.authkey)
Expand All @@ -213,6 +210,7 @@ def handle_request(self, c):
msg = ('#TRACEBACK', format_exc())
else:
msg = ('#RETURN', result)

try:
c.send(msg)
except Exception as e:
Expand All @@ -224,7 +222,17 @@ def handle_request(self, c):
util.info(' ... request was %r', request)
util.info(' ... exception was %r', e)

c.close()
def handle_request(self, conn):
'''
Handle a new connection
'''
try:
self._handle_request(conn)
except SystemExit:
# Server.serve_client() calls sys.exit(0) on EOF
pass
finally:
conn.close()

def serve_client(self, conn):
'''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :mod:`multiprocessing` ``Server`` class now explicitly catchs
:exc:`SystemExit` and closes the client connection in this case. It happens
when the ``Server.serve_client()`` method reachs the end of file (EOF).