@@ -4628,25 +4628,36 @@ def test_thread_recv_while_main_thread_sends(self):
46284628 # if a thread started to infinitely block until data was received, calls
46294629 # to send() would deadlock, because it would wait forever on the lock
46304630 # that the recv() call held.
4631- data = b"a" * 500
4631+ data = b"1" * 50
4632+ event = threading .Event ()
4633+ event2 = threading .Event ()
46324634 def background (sock ):
4633- received = sock .recv (500 )
4635+ event .set ()
4636+ event2 .wait ()
4637+ received = sock .recv (50 )
46344638 self .assertEqual (received , data )
46354639
46364640 client_context , server_context , hostname = testing_context ()
4637- server = ThreadedEchoServer (context = server_context )
4641+ server = ThreadedEchoServer (context = server_context ,
4642+ chatty = False , connectionchatty = False )
46384643 with server :
46394644 with client_context .wrap_socket (socket .socket (),
46404645 server_hostname = hostname ) as sock :
46414646 sock .connect ((HOST , server .port ))
4647+ sock .settimeout (5 )
46424648 with threading_helper .catch_threading_exception () as cm :
4643- thread = threading .Thread (target = background , args = (sock ,))
4649+ thread = threading .Thread (target = background ,
4650+ args = (sock ,), daemon = True )
46444651 thread .start ()
4645- sock .sendall (data )
4652+ # Use two events to prevent some race conditions here.
4653+ event .wait ()
4654+ event2 .set ()
4655+ sock .sendall (b"1" * 50 )
46464656 thread .join ()
46474657 if cm .exc_value is not None :
46484658 raise cm .exc_value
46494659
4660+
46504661@unittest .skipUnless (has_tls_version ('TLSv1_3' ) and ssl .HAS_PHA ,
46514662 "Test needs TLS 1.3 PHA" )
46524663class TestPostHandshakeAuth (unittest .TestCase ):
0 commit comments