Skip to content

Commit

Permalink
More reliable multithread tests on slow machines
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdavis committed Apr 23, 2012
1 parent 6b056ee commit 326b710
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/test_pooling.py
Expand Up @@ -86,8 +86,8 @@ def run_in_request():

# Join thread
acquired = False
for i in range(10):
time.sleep(0.1)
for i in range(30):
time.sleep(0.5)
acquired = lock.acquire(0)
if acquired:
break
Expand Down
9 changes: 7 additions & 2 deletions test/test_threads.py
Expand Up @@ -355,7 +355,7 @@ def test_server_disconnect(self):
t.start()

# Wait for the threads to reach the rendezvous
state.ev_arrived.wait(1)
state.ev_arrived.wait(10)
self.assertTrue(state.ev_arrived.isSet(), "Thread timeout")

try:
Expand All @@ -365,6 +365,11 @@ def test_server_disconnect(self):
for t in threads:
t.request_sock.close()

# Finally, ensure the main thread's socket's last_checkout is
# updated:
collection.find_one()

# ... and close it:
request_sock.close()

# Doing an operation on the connection raises an AutoReconnect and
Expand All @@ -376,7 +381,7 @@ def test_server_disconnect(self):
state.ev_resume.set()

for t in threads:
t.join(1)
t.join(10)
self.assertFalse(t.isAlive(), "Thread timeout")

for t in threads:
Expand Down

0 comments on commit 326b710

Please sign in to comment.