@@ -153,7 +153,9 @@ async def request(channel):
153153 msg = request .SerializeToString ()
154154 return await channel .unary_unary (rpc_call )(msg )
155155
156- await run_with_test_server (request , interceptors = [aio_server_interceptor ()])
156+ await run_with_test_server (
157+ request , interceptors = [aio_server_interceptor ()]
158+ )
157159
158160 spans_list = self .memory_exporter .get_finished_spans ()
159161 self .assertEqual (len (spans_list ), 1 )
@@ -205,7 +207,11 @@ async def request(channel):
205207 msg = request .SerializeToString ()
206208 return await channel .unary_unary (rpc_call )(msg )
207209
208- await run_with_test_server (request , servicer = TwoSpanServicer (), interceptors = [aio_server_interceptor ()])
210+ await run_with_test_server (
211+ request ,
212+ servicer = TwoSpanServicer (),
213+ interceptors = [aio_server_interceptor ()],
214+ )
209215
210216 spans_list = self .memory_exporter .get_finished_spans ()
211217 self .assertEqual (len (spans_list ), 2 )
@@ -252,7 +258,9 @@ async def request(channel):
252258 async for response in channel .unary_stream (rpc_call )(msg ):
253259 print (response )
254260
255- await run_with_test_server (request , interceptors = [aio_server_interceptor ()])
261+ await run_with_test_server (
262+ request , interceptors = [aio_server_interceptor ()]
263+ )
256264
257265 spans_list = self .memory_exporter .get_finished_spans ()
258266 self .assertEqual (len (spans_list ), 1 )
@@ -306,7 +314,11 @@ async def request(channel):
306314 async for response in channel .unary_stream (rpc_call )(msg ):
307315 print (response )
308316
309- await run_with_test_server (request , servicer = TwoSpanServicer (), interceptors = [aio_server_interceptor ()])
317+ await run_with_test_server (
318+ request ,
319+ servicer = TwoSpanServicer (),
320+ interceptors = [aio_server_interceptor ()],
321+ )
310322
311323 spans_list = self .memory_exporter .get_finished_spans ()
312324 self .assertEqual (len (spans_list ), 2 )
@@ -366,7 +378,11 @@ async def request(channel):
366378 lifetime_servicer = SpanLifetimeServicer ()
367379 active_span_before_call = trace .get_current_span ()
368380
369- await run_with_test_server (request , servicer = lifetime_servicer , interceptors = [aio_server_interceptor ()])
381+ await run_with_test_server (
382+ request ,
383+ servicer = lifetime_servicer ,
384+ interceptors = [aio_server_interceptor ()],
385+ )
370386
371387 active_span_in_handler = lifetime_servicer .span
372388 active_span_after_call = trace .get_current_span ()
@@ -389,7 +405,9 @@ async def sequential_requests(channel):
389405 await request (channel )
390406 await request (channel )
391407
392- await run_with_test_server (sequential_requests , interceptors = [aio_server_interceptor ()])
408+ await run_with_test_server (
409+ sequential_requests , interceptors = [aio_server_interceptor ()]
410+ )
393411
394412 spans_list = self .memory_exporter .get_finished_spans ()
395413 self .assertEqual (len (spans_list ), 2 )
@@ -449,7 +467,9 @@ async def concurrent_requests(channel):
449467 await asyncio .gather (request (channel ), request (channel ))
450468
451469 await run_with_test_server (
452- concurrent_requests , servicer = LatchedServicer (), interceptors = [aio_server_interceptor ()]
470+ concurrent_requests ,
471+ servicer = LatchedServicer (),
472+ interceptors = [aio_server_interceptor ()],
453473 )
454474
455475 spans_list = self .memory_exporter .get_finished_spans ()
@@ -503,7 +523,11 @@ async def request(channel):
503523 self .assertEqual (cm .exception .code (), grpc .StatusCode .INTERNAL )
504524 self .assertEqual (cm .exception .details (), failure_message )
505525
506- await run_with_test_server (request , servicer = AbortServicer (), interceptors = [aio_server_interceptor ()])
526+ await run_with_test_server (
527+ request ,
528+ servicer = AbortServicer (),
529+ interceptors = [aio_server_interceptor ()],
530+ )
507531
508532 spans_list = self .memory_exporter .get_finished_spans ()
509533 self .assertEqual (len (spans_list ), 1 )
@@ -568,7 +592,11 @@ async def request(channel):
568592 )
569593 self .assertEqual (cm .exception .details (), failure_message )
570594
571- await run_with_test_server (request , servicer = AbortServicer (), interceptors = [aio_server_interceptor ()])
595+ await run_with_test_server (
596+ request ,
597+ servicer = AbortServicer (),
598+ interceptors = [aio_server_interceptor ()],
599+ )
572600
573601 spans_list = self .memory_exporter .get_finished_spans ()
574602 self .assertEqual (len (spans_list ), 1 )
@@ -616,10 +644,14 @@ async def request(channel):
616644 return await channel .unary_unary (rpc_call )(msg )
617645
618646 class MockInterceptor (grpc .aio .ServerInterceptor ):
619- async def intercept_service (self , continuation , handler_call_details ):
647+ async def intercept_service (
648+ self , continuation , handler_call_details
649+ ):
620650 return await continuation (handler_call_details )
621651
622- await run_with_test_server (request , interceptors = (MockInterceptor (),))
652+ await run_with_test_server (
653+ request , interceptors = (MockInterceptor (),)
654+ )
623655
624656 finally :
625657 grpc_server_instrumentor .uninstrument ()
@@ -651,6 +683,7 @@ async def intercept_service(self, continuation, handler_call_details):
651683 },
652684 )
653685
686+
654687def get_latch (num ):
655688 """Get a countdown latch function for use in n threads."""
656689 cv = asyncio .Condition ()
0 commit comments