心よ。心よ。ここは、悪い所よ。

pull/20838/head
Richard Belleville 5 years ago
parent 026d0e6af6
commit 9b058aa157
  1. 2
      src/python/grpcio_tests/tests/unit/_reconnect_test.py
  2. 2
      src/python/grpcio_tests/tests/unit/framework/common/__init__.py

@ -42,7 +42,7 @@ class ReconnectTest(unittest.TestCase):
'UnaryUnary': 'UnaryUnary':
grpc.unary_unary_rpc_method_handler(_handle_unary_unary) grpc.unary_unary_rpc_method_handler(_handle_unary_unary)
}) })
options=(('grpc.so_reuseport', 0),) options=(('grpc.so_reuseport', 1),)
with bound_socket() as (host, port): with bound_socket() as (host, port):
addr = '{}:{}'.format(host, port) addr = '{}:{}'.format(host, port)
server = grpc.server(server_pool, (handler,), options=options) server = grpc.server(server_pool, (handler,), options=options)

@ -15,7 +15,6 @@
import contextlib import contextlib
import socket import socket
def get_socket(bind_address='localhost', def get_socket(bind_address='localhost',
listen=True, listen=True,
sock_options=(socket.SO_REUSEPORT,)): sock_options=(socket.SO_REUSEPORT,)):
@ -49,6 +48,7 @@ def get_socket(bind_address='localhost',
sock.listen(1) sock.listen(1)
return bind_address, sock.getsockname()[1], sock return bind_address, sock.getsockname()[1], sock
except socket.error: except socket.error:
sock.close()
continue continue
raise RuntimeError("Failed to bind to {} with sock_options {}".format( raise RuntimeError("Failed to bind to {} with sock_options {}".format(
bind_address, sock_options)) bind_address, sock_options))

Loading…
Cancel
Save