File tree Expand file tree Collapse file tree 2 files changed +23
-23
lines changed Expand file tree Collapse file tree 2 files changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -40,18 +40,7 @@ def asyncSetUpModule():
40
40
pass
41
41
42
42
43
- if _IS_SYNC :
44
-
45
- class SimpleOp (threading .Thread ):
46
- def __init__ (self , client ):
47
- super ().__init__ ()
48
- self .client = client
49
- self .passed = False
50
-
51
- def run (self ):
52
- self .client .db .command ("ping" )
53
- self .passed = True # No exception raised.
54
- else :
43
+ if not _IS_SYNC :
55
44
56
45
class SimpleOp :
57
46
def __init__ (self , client ):
@@ -68,6 +57,17 @@ def start(self):
68
57
69
58
async def join (self ):
70
59
await self .task
60
+ else :
61
+
62
+ class SimpleOp (threading .Thread ):
63
+ def __init__ (self , client ):
64
+ super ().__init__ ()
65
+ self .client = client
66
+ self .passed = False
67
+
68
+ def run (self ):
69
+ self .client .db .command ("ping" )
70
+ self .passed = True # No exception raised.
71
71
72
72
73
73
async def do_simple_op (client , nthreads ):
Original file line number Diff line number Diff line change @@ -40,35 +40,35 @@ def setUpModule():
40
40
pass
41
41
42
42
43
- if _IS_SYNC :
43
+ if not _IS_SYNC :
44
44
45
- class SimpleOp ( threading . Thread ) :
45
+ class SimpleOp :
46
46
def __init__ (self , client ):
47
- super (). __init__ ()
47
+ self . task : asyncio . Task
48
48
self .client = client
49
49
self .passed = False
50
50
51
51
def run (self ):
52
52
self .client .db .command ("ping" )
53
53
self .passed = True # No exception raised.
54
+
55
+ def start (self ):
56
+ self .task = asyncio .create_task (self .run ())
57
+
58
+ def join (self ):
59
+ self .task
54
60
else :
55
61
56
- class SimpleOp :
62
+ class SimpleOp ( threading . Thread ) :
57
63
def __init__ (self , client ):
58
- self . task : asyncio . Task
64
+ super (). __init__ ()
59
65
self .client = client
60
66
self .passed = False
61
67
62
68
def run (self ):
63
69
self .client .db .command ("ping" )
64
70
self .passed = True # No exception raised.
65
71
66
- def start (self ):
67
- self .task = asyncio .create_task (self .run ())
68
-
69
- def join (self ):
70
- self .task
71
-
72
72
73
73
def do_simple_op (client , nthreads ):
74
74
threads = [SimpleOp (client ) for _ in range (nthreads )]
You can’t perform that action at this time.
0 commit comments