mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Suppress transient refleaks in test_asyncore
This commit is contained in:
parent
abc9f70381
commit
f829d1f551
1 changed files with 29 additions and 25 deletions
|
|
@ -319,16 +319,18 @@ class DispatcherWithSendTests(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
asyncore.close_all()
|
asyncore.close_all()
|
||||||
|
|
||||||
|
@test_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 = test_support.bind_port(self.sock)
|
port = test_support.bind_port(sock)
|
||||||
|
|
||||||
cap = StringIO()
|
cap = StringIO()
|
||||||
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
|
# wait a little longer for the server to initialize (it sometimes
|
||||||
# refuses connections on slow machines without this wait)
|
# refuses connections on slow machines without this wait)
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
@ -336,7 +338,7 @@ class DispatcherWithSendTests(unittest.TestCase):
|
||||||
data = "Suppose there isn't a 16-ton weight?"
|
data = "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)
|
||||||
|
|
@ -350,9 +352,11 @@ class DispatcherWithSendTests(unittest.TestCase):
|
||||||
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):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue