mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Merged revisions 75826 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75826 | antoine.pitrou | 2009-10-27 19:36:47 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_asyncore ........
This commit is contained in:
		
							parent
							
								
									8fbb29b7ef
								
							
						
					
					
						commit
						5ed353c293
					
				
					 1 changed files with 29 additions and 25 deletions
				
			
		| 
						 | 
				
			
			@ -320,16 +320,18 @@ def setUp(self):
 | 
			
		|||
    def tearDown(self):
 | 
			
		||||
        asyncore.close_all()
 | 
			
		||||
 | 
			
		||||
    @support.reap_threads
 | 
			
		||||
    def test_send(self):
 | 
			
		||||
        self.evt = threading.Event()
 | 
			
		||||
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
			
		||||
        self.sock.settimeout(3)
 | 
			
		||||
        self.port = support.bind_port(self.sock)
 | 
			
		||||
        evt = threading.Event()
 | 
			
		||||
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
			
		||||
        sock.settimeout(3)
 | 
			
		||||
        port = support.bind_port(sock)
 | 
			
		||||
 | 
			
		||||
        cap = BytesIO()
 | 
			
		||||
        args = (self.evt, cap, self.sock)
 | 
			
		||||
        threading.Thread(target=capture_server, args=args).start()
 | 
			
		||||
 | 
			
		||||
        args = (evt, cap, sock)
 | 
			
		||||
        t = threading.Thread(target=capture_server, args=args)
 | 
			
		||||
        t.start()
 | 
			
		||||
        try:
 | 
			
		||||
            # wait a little longer for the server to initialize (it sometimes
 | 
			
		||||
            # refuses connections on slow machines without this wait)
 | 
			
		||||
            time.sleep(0.2)
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +339,7 @@ def test_send(self):
 | 
			
		|||
            data = b"Suppose there isn't a 16-ton weight?"
 | 
			
		||||
            d = dispatcherwithsend_noread()
 | 
			
		||||
            d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
			
		||||
        d.connect((HOST, self.port))
 | 
			
		||||
            d.connect((HOST, port))
 | 
			
		||||
 | 
			
		||||
            # give time for socket to connect
 | 
			
		||||
            time.sleep(0.1)
 | 
			
		||||
| 
						 | 
				
			
			@ -351,9 +353,11 @@ def test_send(self):
 | 
			
		|||
                asyncore.poll()
 | 
			
		||||
                n -= 1
 | 
			
		||||
 | 
			
		||||
        self.evt.wait()
 | 
			
		||||
            evt.wait()
 | 
			
		||||
 | 
			
		||||
            self.assertEqual(cap.getvalue(), data*2)
 | 
			
		||||
        finally:
 | 
			
		||||
            t.join()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue