mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +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,40 +320,44 @@ def setUp(self):
 | 
				
			||||||
    def tearDown(self):
 | 
					    def tearDown(self):
 | 
				
			||||||
        asyncore.close_all()
 | 
					        asyncore.close_all()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @support.reap_threads
 | 
				
			||||||
    def test_send(self):
 | 
					    def test_send(self):
 | 
				
			||||||
        self.evt = threading.Event()
 | 
					        evt = threading.Event()
 | 
				
			||||||
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
					        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
				
			||||||
        self.sock.settimeout(3)
 | 
					        sock.settimeout(3)
 | 
				
			||||||
        self.port = support.bind_port(self.sock)
 | 
					        port = support.bind_port(sock)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cap = BytesIO()
 | 
					        cap = BytesIO()
 | 
				
			||||||
        args = (self.evt, cap, self.sock)
 | 
					        args = (evt, cap, sock)
 | 
				
			||||||
        threading.Thread(target=capture_server, args=args).start()
 | 
					        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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # wait a little longer for the server to initialize (it sometimes
 | 
					            data = b"Suppose there isn't a 16-ton weight?"
 | 
				
			||||||
        # refuses connections on slow machines without this wait)
 | 
					            d = dispatcherwithsend_noread()
 | 
				
			||||||
        time.sleep(0.2)
 | 
					            d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
				
			||||||
 | 
					            d.connect((HOST, port))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        data = b"Suppose there isn't a 16-ton weight?"
 | 
					            # give time for socket to connect
 | 
				
			||||||
        d = dispatcherwithsend_noread()
 | 
					            time.sleep(0.1)
 | 
				
			||||||
        d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
					 | 
				
			||||||
        d.connect((HOST, self.port))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # give time for socket to connect
 | 
					            d.send(data)
 | 
				
			||||||
        time.sleep(0.1)
 | 
					            d.send(data)
 | 
				
			||||||
 | 
					            d.send(b'\n')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        d.send(data)
 | 
					            n = 1000
 | 
				
			||||||
        d.send(data)
 | 
					            while d.out_buffer and n > 0:
 | 
				
			||||||
        d.send(b'\n')
 | 
					                asyncore.poll()
 | 
				
			||||||
 | 
					                n -= 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        n = 1000
 | 
					            evt.wait()
 | 
				
			||||||
        while d.out_buffer and n > 0:
 | 
					 | 
				
			||||||
            asyncore.poll()
 | 
					 | 
				
			||||||
            n -= 1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.evt.wait()
 | 
					            self.assertEqual(cap.getvalue(), data*2)
 | 
				
			||||||
 | 
					        finally:
 | 
				
			||||||
        self.assertEqual(cap.getvalue(), data*2)
 | 
					            t.join()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
 | 
					class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue