-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
import asyncio | ||
|
||
import grpc | ||
|
||
from duetector.analyzer.jaeger.proto.query_pb2 import * | ||
from duetector.analyzer.jaeger.proto.query_pb2_grpc import * | ||
|
||
|
||
async def run() -> None: | ||
async with grpc.aio.insecure_channel("localhost:16685") as channel: | ||
stub = QueryServiceStub(channel) | ||
response = await stub.GetServices(GetServicesRequest()) | ||
print(response) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(run()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import asyncio | ||
|
||
from fastapi.concurrency import run_in_threadpool | ||
|
||
|
||
async def ensure_async(f: callable, *args, **kwargs): | ||
# await async function, run sync function in thread pool | ||
if asyncio.iscoroutinefunction(f): | ||
return await f(*args, **kwargs) | ||
|
||
return await run_in_threadpool(f, *args, **kwargs) |