Make the socket creation function 2/3 agnostic

pull/21607/head
Lidi Zheng 5 years ago
parent e479a78b7c
commit b74476417d
  1. 2
      src/python/grpcio/grpc/experimental/aio/_channel.py
  2. 5
      src/python/grpcio_tests/tests/unit/framework/common/__init__.py

@ -13,7 +13,7 @@
# limitations under the License.
"""Invocation-side implementation of gRPC Asyncio Python."""
import asyncio
from typing import Any, Optional, Text
from typing import Any, Optional, Sequence, Text
import grpc
from grpc import _common

@ -63,6 +63,11 @@ def get_socket(bind_address='localhost',
raise
else:
continue
# For PY2, socket.error is a child class of IOError; for PY3, it is
# pointing to OSError. We need this catch to make it 2/3 agnostic.
except socket.error: # pylint: disable=duplicate-except
sock.close()
continue
raise RuntimeError("Failed to bind to {} with sock_options {}".format(
bind_address, sock_options))

Loading…
Cancel
Save