Commit 5ed353c2 authored by Antoine Pitrou's avatar Antoine Pitrou

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
........
parent 8fbb29b7
...@@ -320,40 +320,44 @@ class DispatcherWithSendTests(unittest.TestCase): ...@@ -320,40 +320,44 @@ class DispatcherWithSendTests(unittest.TestCase):
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()
# wait a little longer for the server to initialize (it sometimes try:
# refuses connections on slow machines without this wait) # wait a little longer for the server to initialize (it sometimes
time.sleep(0.2) # refuses connections on slow machines without this wait)
time.sleep(0.2)
data = b"Suppose there isn't a 16-ton weight?" data = b"Suppose there isn't a 16-ton weight?"
d = dispatcherwithsend_noread() d = dispatcherwithsend_noread()
d.create_socket(socket.AF_INET, socket.SOCK_STREAM) d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
d.connect((HOST, self.port)) d.connect((HOST, port))
# give time for socket to connect # give time for socket to connect
time.sleep(0.1) time.sleep(0.1)
d.send(data) d.send(data)
d.send(data) d.send(data)
d.send(b'\n') d.send(b'\n')
n = 1000 n = 1000
while d.out_buffer and n > 0: while d.out_buffer and n > 0:
asyncore.poll() asyncore.poll()
n -= 1 n -= 1
self.evt.wait() evt.wait()
self.assertEqual(cap.getvalue(), data*2) self.assertEqual(cap.getvalue(), data*2)
finally:
t.join()
class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment