src/python/grpcio_tests/tests_aio/interop/server.py
Go to the documentation of this file.
1 # Copyright 2019 The gRPC Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """The gRPC interoperability test server using AsyncIO stack."""
15 
16 import argparse
17 import asyncio
18 import logging
19 
20 import grpc
21 
22 from tests.interop import server as interop_server_lib
23 from tests_aio.unit import _test_server
24 
25 logging.basicConfig(level=logging.DEBUG)
26 _LOGGER = logging.getLogger(__name__)
27 _LOGGER.setLevel(logging.DEBUG)
28 
29 
30 async def serve():
31  args = interop_server_lib.parse_interop_server_arguments()
32 
33  if args.use_tls or args.use_alts:
34  credentials = interop_server_lib.get_server_credentials(args.use_tls)
35  address, server = await _test_server.start_test_server(
36  port=args.port, secure=True, server_credentials=credentials)
37  else:
38  address, server = await _test_server.start_test_server(
39  port=args.port,
40  secure=False,
41  )
42 
43  _LOGGER.info('Server serving at %s', address)
44  await server.wait_for_termination()
45  _LOGGER.info('Server stopped; exiting.')
46 
47 
48 if __name__ == '__main__':
49  asyncio.get_event_loop().run_until_complete(serve())
tests_aio.unit
Definition: src/python/grpcio_tests/tests_aio/unit/__init__.py:1
tests.interop
Definition: src/python/grpcio_tests/tests/interop/__init__.py:1
tests_aio.interop.server.serve
def serve()
Definition: src/python/grpcio_tests/tests_aio/interop/server.py:30


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:11