Skip to content

Commit 5cd8be8

Browse files
committed
response to review
1 parent 4b8f936 commit 5cd8be8

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

test/asynchronous/test_mongos_load_balancing.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,11 @@
3434
_IS_SYNC = False
3535

3636

37-
@async_client_context.require_connection
38-
@async_client_context.require_no_load_balancer
39-
def asyncSetUpModule():
40-
pass
41-
42-
4337
if not _IS_SYNC:
4438

4539
class SimpleOp:
4640
def __init__(self, client):
47-
self.task: asyncio.Task
41+
self.task = asyncio.create_task(self.run())
4842
self.client = client
4943
self.passed = False
5044

@@ -53,7 +47,7 @@ async def run(self):
5347
self.passed = True # No exception raised.
5448

5549
def start(self):
56-
self.task = asyncio.create_task(self.run())
50+
pass
5751

5852
async def join(self):
5953
await self.task
@@ -70,15 +64,15 @@ def run(self):
7064
self.passed = True # No exception raised.
7165

7266

73-
async def do_simple_op(client, nthreads):
74-
threads = [SimpleOp(client) for _ in range(nthreads)]
75-
for t in threads:
67+
async def do_simple_op(client, ntasks):
68+
tasks = [SimpleOp(client) for _ in range(ntasks)]
69+
for t in tasks:
7670
t.start()
7771

78-
for t in threads:
72+
for t in tasks:
7973
await t.join()
8074

81-
for t in threads:
75+
for t in tasks:
8276
assert t.passed
8377

8478

@@ -90,6 +84,11 @@ async def writable_addresses(topology):
9084

9185

9286
class TestMongosLoadBalancing(AsyncMockClientTest):
87+
@async_client_context.require_connection
88+
@async_client_context.require_no_load_balancer
89+
async def asyncSetUp(self):
90+
await super().asyncSetUp()
91+
9392
def mock_client(self, **kwargs):
9493
mock_client = AsyncMockClient(
9594
standalones=[],

test/test_mongos_load_balancing.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,11 @@
3434
_IS_SYNC = True
3535

3636

37-
@client_context.require_connection
38-
@client_context.require_no_load_balancer
39-
def setUpModule():
40-
pass
41-
42-
4337
if not _IS_SYNC:
4438

4539
class SimpleOp:
4640
def __init__(self, client):
47-
self.task: asyncio.Task
41+
self.task = asyncio.create_task(self.run())
4842
self.client = client
4943
self.passed = False
5044

@@ -53,7 +47,7 @@ def run(self):
5347
self.passed = True # No exception raised.
5448

5549
def start(self):
56-
self.task = asyncio.create_task(self.run())
50+
pass
5751

5852
def join(self):
5953
self.task
@@ -70,15 +64,15 @@ def run(self):
7064
self.passed = True # No exception raised.
7165

7266

73-
def do_simple_op(client, nthreads):
74-
threads = [SimpleOp(client) for _ in range(nthreads)]
75-
for t in threads:
67+
def do_simple_op(client, ntasks):
68+
tasks = [SimpleOp(client) for _ in range(ntasks)]
69+
for t in tasks:
7670
t.start()
7771

78-
for t in threads:
72+
for t in tasks:
7973
t.join()
8074

81-
for t in threads:
75+
for t in tasks:
8276
assert t.passed
8377

8478

@@ -90,6 +84,11 @@ def writable_addresses(topology):
9084

9185

9286
class TestMongosLoadBalancing(MockClientTest):
87+
@client_context.require_connection
88+
@client_context.require_no_load_balancer
89+
def setUp(self):
90+
super().setUp()
91+
9392
def mock_client(self, **kwargs):
9493
mock_client = MockClient(
9594
standalones=[],

0 commit comments

Comments
 (0)