Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python tests] Allow passing kwargs to grpc.server in test_server #36455

Closed
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/python/grpcio_tests/tests/unit/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# limitations under the License.
"""Common code used throughout tests of gRPC."""

import ast
import collections
from concurrent import futures
import os
import threading

import grpc
Expand Down Expand Up @@ -110,9 +112,16 @@ def test_server(max_workers=10, reuse_port=False):

These servers have SO_REUSEPORT disabled to prevent cross-talk.
"""
server_kwargs = os.environ.get("GRPC_ADDITIONAL_SERVER_KWARGS", "")
gnossen marked this conversation as resolved.
Show resolved Hide resolved
try:
server_kwargs = ast.literal_eval(server_kwargs)
except Exception: # pylint: disable=broad-except
server_kwargs = {}

return grpc.server(
futures.ThreadPoolExecutor(max_workers=max_workers),
options=(("grpc.so_reuseport", int(reuse_port)),),
**server_kwargs,
)


Expand Down