MCPcopy Create free account
hub / github.com/tensorflow/tensorboard / run

Method run

tensorboard/util/grpc_util_test.py:53–73  ·  view source on GitHub ↗

Context manager to run the gRPC server and yield a client for it.

(self)

Source from the content-addressed store, hash-verified

51
52 @contextlib.contextmanager
53 def run(self):
54 """Context manager to run the gRPC server and yield a client for it."""
55 server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
56 grpc_util_test_pb2_grpc.add_TestServiceServicer_to_server(self, server)
57 port = server.add_secure_port(
58 "localhost:0", grpc.local_server_credentials()
59 )
60
61 def launch_server():
62 server.start()
63 server.wait_for_termination()
64
65 thread = threading.Thread(target=launch_server, name="TestGrpcServer")
66 thread.daemon = True
67 thread.start()
68 with grpc.secure_channel(
69 "localhost:%d" % port, grpc.local_channel_credentials()
70 ) as channel:
71 yield grpc_util_test_pb2_grpc.TestServiceStub(channel)
72 server.stop(grace=None)
73 thread.join()
74
75
76class CallWithRetriesTest(tb_test.TestCase):

Calls 3

stopMethod · 0.80
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected