[Python-checkins] r70717 - in python/trunk: Lib/multiprocessing/connection.py Lib/test/test_multiprocessing.py Misc/NEWS
jesse.noller
python-checkins at python.org
Mon Mar 30 17:50:42 CEST 2009
Author: jesse.noller
Date: Mon Mar 30 17:50:42 2009
New Revision: 70717
Log:
Issue 5177: use socket.SO_REUSEADDR on multiprocessing SocketManager sockets
Modified:
python/trunk/Lib/multiprocessing/connection.py
python/trunk/Lib/test/test_multiprocessing.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/multiprocessing/connection.py
==============================================================================
--- python/trunk/Lib/multiprocessing/connection.py (original)
+++ python/trunk/Lib/multiprocessing/connection.py Mon Mar 30 17:50:42 2009
@@ -214,6 +214,7 @@
'''
def __init__(self, address, family, backlog=1):
self._socket = socket.socket(getattr(socket, family))
+ self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._socket.bind(address)
self._socket.listen(backlog)
self._address = self._socket.getsockname()
Modified: python/trunk/Lib/test/test_multiprocessing.py
==============================================================================
--- python/trunk/Lib/test/test_multiprocessing.py (original)
+++ python/trunk/Lib/test/test_multiprocessing.py Mon Mar 30 17:50:42 2009
@@ -1189,6 +1189,30 @@
del queue
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()
+
#
#
#
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Mon Mar 30 17:50:42 2009
@@ -197,6 +197,10 @@
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
defined (part of issue #5035).
More information about the Python-checkins
mailing list