File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ import asyncio
2
+ import concurrent .futures
3
+
4
+ from uvloop import _testbase as tb
5
+
6
+
7
+ def fib (n ):
8
+ if n < 2 :
9
+ return 1
10
+ return fib (n - 2 ) + fib (n - 1 )
11
+
12
+
13
+ class _TestExecutors :
14
+
15
+ def run_pool_test (self , pool_factory ):
16
+ async def run ():
17
+ pool = pool_factory ()
18
+ with pool :
19
+ coros = []
20
+ for i in range (0 , 10 ):
21
+ coros .append (self .loop .run_in_executor (pool , fib , i ))
22
+ res = await asyncio .gather (* coros , loop = self .loop )
23
+ self .assertEqual (res , fib10 )
24
+
25
+ fib10 = [fib (i ) for i in range (10 )]
26
+ self .loop .run_until_complete (run ())
27
+
28
+ def test_executors_process_pool_01 (self ):
29
+ self .run_pool_test (concurrent .futures .ProcessPoolExecutor )
30
+
31
+ def test_executors_process_pool_02 (self ):
32
+ self .run_pool_test (concurrent .futures .ThreadPoolExecutor )
33
+
34
+
35
+ class TestUVExecutors (_TestExecutors , tb .UVTestCase ):
36
+ pass
37
+
38
+
39
+ class TestAIOExecutors (_TestExecutors , tb .AIOTestCase ):
40
+ pass
You can’t perform that action at this time.
0 commit comments