File tree 1 file changed +10
-8
lines changed
1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
- from concurrent .futures import ThreadPoolExecutor
1
+ from concurrent .futures import ThreadPoolExecutor , as_completed
2
2
3
3
import pytest
4
4
from pytest_benchmark .fixture import BenchmarkFixture
7
7
8
8
9
9
def do_work (client : Client ):
10
- def delete (path : str ):
11
- client .delete (path )
10
+ def func (path : str ):
11
+ client .create (path ).close ()
12
+ return client .delete (path )
12
13
13
14
with ThreadPoolExecutor (100 ) as executor :
14
- for i in range (100 ):
15
- executor .submit (delete , f"/bench{ i } " )
15
+ futures = []
16
+ for i in range (1000 ):
17
+ futures .append (executor .submit (func , f"/bench{ i } " ))
18
+
19
+ for future in as_completed (futures ):
20
+ assert future .result ()
16
21
17
22
18
23
@pytest .mark .benchmark
19
24
def test_threading (client : Client , benchmark : BenchmarkFixture ):
20
- for i in range (100 ):
21
- client .create (f"/bench{ i } " ).close ()
22
-
23
25
benchmark (do_work , client )
You can’t perform that action at this time.
0 commit comments