File tree Expand file tree Collapse file tree 2 files changed +14
-24
lines changed Expand file tree Collapse file tree 2 files changed +14
-24
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ async def test_lazy_connect(self):
101
101
await async_wait_until (lambda : len (client .nodes ) == 3 , "connect to all mongoses" )
102
102
103
103
async def test_failover (self ):
104
- nthreads = 10
104
+ ntasks = 10
105
105
client = await connected (self .mock_client (localThresholdMS = 0.001 ))
106
106
await async_wait_until (lambda : len (client .nodes ) == 3 , "connect to all mongoses" )
107
107
@@ -121,19 +121,14 @@ async def f():
121
121
122
122
passed .append (True )
123
123
124
- if _IS_SYNC :
125
- threads = [threading .Thread (target = f ) for _ in range (nthreads )]
126
- for t in threads :
127
- t .start ()
124
+ tasks = [ConcurrentRunner (target = f ) for _ in range (ntasks )]
125
+ for t in tasks :
126
+ await t .start ()
128
127
129
- for t in threads :
130
- t .join ()
131
- else :
132
- tasks = [asyncio .create_task (f ()) for _ in range (nthreads )]
133
- for t in tasks :
134
- await t
128
+ for t in tasks :
129
+ await t .join ()
135
130
136
- self .assertEqual (nthreads , len (passed ))
131
+ self .assertEqual (ntasks , len (passed ))
137
132
138
133
# Down host removed from list.
139
134
self .assertEqual (2 , len (client .nodes ))
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ def test_lazy_connect(self):
101
101
wait_until (lambda : len (client .nodes ) == 3 , "connect to all mongoses" )
102
102
103
103
def test_failover (self ):
104
- nthreads = 10
104
+ ntasks = 10
105
105
client = connected (self .mock_client (localThresholdMS = 0.001 ))
106
106
wait_until (lambda : len (client .nodes ) == 3 , "connect to all mongoses" )
107
107
@@ -121,19 +121,14 @@ def f():
121
121
122
122
passed .append (True )
123
123
124
- if _IS_SYNC :
125
- threads = [threading .Thread (target = f ) for _ in range (nthreads )]
126
- for t in threads :
127
- t .start ()
124
+ tasks = [ConcurrentRunner (target = f ) for _ in range (ntasks )]
125
+ for t in tasks :
126
+ t .start ()
128
127
129
- for t in threads :
130
- t .join ()
131
- else :
132
- tasks = [asyncio .create_task (f ()) for _ in range (nthreads )]
133
- for t in tasks :
134
- t
128
+ for t in tasks :
129
+ t .join ()
135
130
136
- self .assertEqual (nthreads , len (passed ))
131
+ self .assertEqual (ntasks , len (passed ))
137
132
138
133
# Down host removed from list.
139
134
self .assertEqual (2 , len (client .nodes ))
You can’t perform that action at this time.
0 commit comments