Skip to content

Commit a4996f3

Browse files
author
A. Jesse Jiryu Davis
committed
More reliable socket-reclamation tests, especially on Windows
1 parent f9a358c commit a4996f3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

test/test_pooling_base.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
try:
4848
import gevent
49-
from gevent import Greenlet, coros, monkey
49+
from gevent import Greenlet, monkey
5050
has_gevent = True
5151
except ImportError:
5252
has_gevent = False
@@ -254,9 +254,7 @@ def run_mongo_thread(self):
254254
for i in range(self.start_request):
255255
self.connection.start_request()
256256

257-
# A reasonable number of docs here, depending on how many are inserted
258-
# in TestPooling.setUp()
259-
list(self.connection[DB].test.find())
257+
list(self.connection[DB].test.find_one({'$where': delay(0.1)}))
260258
for i in range(self.end_request):
261259
self.connection.end_request()
262260

@@ -286,11 +284,7 @@ def setUp(self):
286284
db.test.drop()
287285
db.unique.insert({"_id": "jesse"})
288286

289-
# In tests like test_max_pool_size, we start some threads that will
290-
# perform simultaneous queries, forcing the pool to give out many
291-
# sockets. We need enough docs here that some threads are still in
292-
# progress when other threads start.
293-
db.test.insert([{} for i in range(3000)])
287+
db.test.insert([{} for i in range(10)])
294288

295289
def tearDown(self):
296290
self.c.close()
@@ -642,7 +636,7 @@ class _TestMaxPoolSize(_TestPoolingBase):
642636
"""
643637
def _test_max_pool_size(self, start_request, end_request):
644638
c = self.get_connection(max_pool_size=4, auto_start_request=False)
645-
nthreads = 40
639+
nthreads = 10
646640

647641
if (
648642
self.use_greenlets and sys.platform == 'darwin'
@@ -756,7 +750,7 @@ def find_slow():
756750
# Javascript function that pauses
757751
where = delay(2)
758752
results['find_slow_result'] = list(db.test.find(
759-
{'$where': where}
753+
{'$where': where}
760754
))
761755

762756
history.append('find_slow done')

0 commit comments

Comments
 (0)