2
2
from unittest import main , IsolatedAsyncioTestCase
3
3
4
4
from surrealdb .connections .async_ws import AsyncWsSurrealConnection
5
+ import sys
5
6
6
7
7
8
class TestAsyncWsSurrealConnection (IsolatedAsyncioTestCase ):
@@ -25,11 +26,16 @@ async def asyncSetUp(self):
25
26
_ = await self .connection .use (namespace = self .namespace , database = self .database_name )
26
27
27
28
async def test_batch (self ):
28
- async with asyncio .TaskGroup () as tg :
29
- tasks = [tg .create_task (self .connection .query ("RETURN sleep(duration::from::millis($d)) or $p**2" , dict (d = 10 if num % 2 else 0 , p = num ))) for num in range (5 )]
29
+ python_version = f"{ sys .version_info .major } .{ sys .version_info .minor } "
30
+ if python_version == "3.9" or python_version == "3.10" :
31
+ print ("async batching is being bypassed due to python versions 3.9 and 3.10 not supporting async task group" )
32
+ else :
33
+ async with asyncio .TaskGroup () as tg :
34
+ tasks = [tg .create_task (self .connection .query ("RETURN sleep(duration::from::millis($d)) or $p**2" , dict (d = 10 if num % 2 else 0 , p = num ))) for num in range (5 )]
35
+
36
+ outcome = [t .result () for t in tasks ]
37
+ self .assertEqual ([0 , 1 , 4 , 9 , 16 ], outcome )
30
38
31
- outcome = [t .result () for t in tasks ]
32
- self .assertEqual ([0 , 1 , 4 , 9 , 16 ], outcome )
33
39
34
40
35
41
if __name__ == "__main__" :
0 commit comments