[Python-checkins] r42185 - python/trunk/Lib/test/test_socket_ssl.py

neal.norwitz python-checkins at python.org
Wed Jan 25 09:39:40 CET 2006


Author: neal.norwitz
Date: Wed Jan 25 09:39:35 2006
New Revision: 42185

Modified:
   python/trunk/Lib/test/test_socket_ssl.py
Log:
There was a race condition where the connector would try to connect
before the listener was ready (on gentoo x86 buildslave).  This
caused the listener to not exit normally since nobody connected to it
(waited in accept()).  The exception was raised in the other thread
and the test failed.

This fix doesn't completely eliminate the race, but should make it
near impossible to trigger.  Hopefully it's good enough.



Modified: python/trunk/Lib/test/test_socket_ssl.py
==============================================================================
--- python/trunk/Lib/test/test_socket_ssl.py	(original)
+++ python/trunk/Lib/test/test_socket_ssl.py	Wed Jan 25 09:39:35 2006
@@ -35,6 +35,7 @@
     # Some random port to connect to.
     PORT = 9934
 
+    listener_ready = threading.Event()
     listener_gone = threading.Event()
 
     # `listener` runs in a thread.  It opens a socket listening on PORT, and
@@ -45,11 +46,13 @@
         s = socket.socket()
         s.bind(('', PORT))
         s.listen(5)
+        listener_ready.set()
         s.accept()
         s = None # reclaim the socket object, which also closes it
         listener_gone.set()
 
     def connector():
+        listener_ready.wait()
         s = socket.socket()
         s.connect(('localhost', PORT))
         listener_gone.wait()


More information about the Python-checkins mailing list