mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Issue 5177: use socket.SO_REUSEADDR on multiprocessing SocketManager sockets
This commit is contained in:
parent
5cb104d1b9
commit
459a648166
3 changed files with 29 additions and 0 deletions
|
@ -214,6 +214,7 @@ class SocketListener(object):
|
||||||
'''
|
'''
|
||||||
def __init__(self, address, family, backlog=1):
|
def __init__(self, address, family, backlog=1):
|
||||||
self._socket = socket.socket(getattr(socket, family))
|
self._socket = socket.socket(getattr(socket, family))
|
||||||
|
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
self._socket.bind(address)
|
self._socket.bind(address)
|
||||||
self._socket.listen(backlog)
|
self._socket.listen(backlog)
|
||||||
self._address = self._socket.getsockname()
|
self._address = self._socket.getsockname()
|
||||||
|
|
|
@ -1189,6 +1189,30 @@ class _TestRemoteManager(BaseTestCase):
|
||||||
del queue
|
del queue
|
||||||
manager.shutdown()
|
manager.shutdown()
|
||||||
|
|
||||||
|
class _TestManagerRestart(BaseTestCase):
|
||||||
|
|
||||||
|
def _putter(self, address, authkey):
|
||||||
|
manager = QueueManager(
|
||||||
|
address=address, authkey=authkey, serializer=SERIALIZER)
|
||||||
|
manager.connect()
|
||||||
|
queue = manager.get_queue()
|
||||||
|
queue.put('hello world')
|
||||||
|
|
||||||
|
def test_rapid_restart(self):
|
||||||
|
authkey = os.urandom(32)
|
||||||
|
manager = QueueManager(
|
||||||
|
address=('localhost', 9999), authkey=authkey, serializer=SERIALIZER)
|
||||||
|
manager.start()
|
||||||
|
|
||||||
|
p = self.Process(target=self._putter, args=(manager.address, authkey))
|
||||||
|
p.start()
|
||||||
|
queue = manager.get_queue()
|
||||||
|
self.assertEqual(queue.get(), 'hello world')
|
||||||
|
manager.shutdown()
|
||||||
|
manager = QueueManager(
|
||||||
|
address=('localhost', 9999), authkey=authkey, serializer=SERIALIZER)
|
||||||
|
manager.start()
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
|
@ -197,6 +197,10 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #5177: Multiprocessing's SocketListener class now uses
|
||||||
|
socket.SO_REUSEADDR on all connections so that the user no longer needs
|
||||||
|
to wait 120 seconds for the socket to expire.
|
||||||
|
|
||||||
- Adjusted _tkinter to compile without warnings when WITH_THREAD is not
|
- Adjusted _tkinter to compile without warnings when WITH_THREAD is not
|
||||||
defined (part of issue #5035).
|
defined (part of issue #5035).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue