44from sanic .response import json , text
55
66from zero import AsyncZeroClient , ZeroClient
7- from zero .protocols .tcp import AsyncTCPClient
87
98# TODO: why we can't use uvloop?
109try :
1918app = Sanic (__name__ )
2019
2120client = ZeroClient ("server" , 5559 )
22- async_client = AsyncZeroClient ("server" , 5559 , protocol = AsyncTCPClient )
21+ async_client = AsyncZeroClient ("server" , 5559 )
2322
2423
2524@app .route ("/hello" )
@@ -30,7 +29,7 @@ async def hello(request):
3029
3130@app .route ("/async_hello" )
3231async def async_hello (request ):
33- resp = await async_client .call ("hello_world " , None )
32+ resp = await async_client .call ("async_hello_world " , None )
3433 return text (resp )
3534
3635
@@ -43,7 +42,7 @@ async def order(request):
4342@app .route ("/async_order" )
4443async def async_order (request ):
4544 resp = await async_client .call (
46- "save_order " , {"user_id" : "1" , "items" : ["apple" , "python" ]}
45+ "async_save_order " , {"user_id" : "1" , "items" : ["apple" , "python" ]}
4746 )
4847 return json (resp )
4948
0 commit comments