mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-43867: multiprocessing Server catchs SystemExit (GH-25441)
The multiprocessing Server class now explicitly catchs SystemExit and closes the client connection in this case. It happens when the Server.serve_client() method reachs the end of file (EOF).
This commit is contained in:
parent
62ec638648
commit
7c29ae1f05
2 changed files with 17 additions and 6 deletions
|
@ -192,11 +192,8 @@ class Server(object):
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
def handle_request(self, c):
|
def _handle_request(self, c):
|
||||||
'''
|
request = None
|
||||||
Handle a new connection
|
|
||||||
'''
|
|
||||||
funcname = result = request = None
|
|
||||||
try:
|
try:
|
||||||
connection.deliver_challenge(c, self.authkey)
|
connection.deliver_challenge(c, self.authkey)
|
||||||
connection.answer_challenge(c, self.authkey)
|
connection.answer_challenge(c, self.authkey)
|
||||||
|
@ -213,6 +210,7 @@ class Server(object):
|
||||||
msg = ('#TRACEBACK', format_exc())
|
msg = ('#TRACEBACK', format_exc())
|
||||||
else:
|
else:
|
||||||
msg = ('#RETURN', result)
|
msg = ('#RETURN', result)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
c.send(msg)
|
c.send(msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -224,7 +222,17 @@ class Server(object):
|
||||||
util.info(' ... request was %r', request)
|
util.info(' ... request was %r', request)
|
||||||
util.info(' ... exception was %r', e)
|
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):
|
def serve_client(self, conn):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -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).
|
Loading…
Add table
Add a link
Reference in a new issue