aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio')
-rw-r--r--src/python/grpcio/README.rst35
-rw-r--r--src/python/grpcio/commands.py64
-rw-r--r--src/python/grpcio/grpc/_adapter/_low.py2
-rw-r--r--src/python/grpcio/grpc/_adapter/_types.py17
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi6
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi9
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi6
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi2
-rw-r--r--src/python/grpcio/grpc/_cython/cygrpc.pxd2
-rw-r--r--src/python/grpcio/grpc/_cython/cygrpc.pyx2
-rw-r--r--src/python/grpcio/grpc/_cython/imports.generated.c6
-rw-r--r--src/python/grpcio/grpc/_cython/imports.generated.h13
-rw-r--r--src/python/grpcio/grpc/_links/invocation.py5
-rw-r--r--src/python/grpcio/grpc/_links/service.py2
-rw-r--r--src/python/grpcio/grpc/beta/_server.py2
-rw-r--r--src/python/grpcio/grpc/beta/implementations.py9
-rw-r--r--src/python/grpcio/grpc/beta/interfaces.py20
-rw-r--r--src/python/grpcio/grpc/framework/alpha/_face_utilities.py12
-rw-r--r--src/python/grpcio/grpc/framework/alpha/_reexport.py4
-rw-r--r--src/python/grpcio/grpc/framework/alpha/exceptions.py5
-rw-r--r--src/python/grpcio/grpc/framework/alpha/interfaces.py32
-rw-r--r--src/python/grpcio/grpc/framework/base/_ingestion.py5
-rw-r--r--src/python/grpcio/grpc/framework/base/_interfaces.py23
-rw-r--r--src/python/grpcio/grpc/framework/base/_reception.py5
-rw-r--r--src/python/grpcio/grpc/framework/base/_transmission.py8
-rw-r--r--src/python/grpcio/grpc/framework/base/interfaces.py38
-rw-r--r--src/python/grpcio/grpc/framework/core/_end.py5
-rw-r--r--src/python/grpcio/grpc/framework/core/_ingestion.py5
-rw-r--r--src/python/grpcio/grpc/framework/core/_interfaces.py26
-rw-r--r--src/python/grpcio/grpc/framework/core/_termination.py7
-rw-r--r--src/python/grpcio/grpc/framework/crust/_control.py3
-rw-r--r--src/python/grpcio/grpc/framework/crust/implementations.py4
-rw-r--r--src/python/grpcio/grpc/framework/face/_control.py3
-rw-r--r--src/python/grpcio/grpc/framework/face/exceptions.py5
-rw-r--r--src/python/grpcio/grpc/framework/face/implementations.py4
-rw-r--r--src/python/grpcio/grpc/framework/face/interfaces.py38
-rw-r--r--src/python/grpcio/grpc/framework/foundation/activated.py4
-rw-r--r--src/python/grpcio/grpc/framework/foundation/callable_util.py5
-rw-r--r--src/python/grpcio/grpc/framework/foundation/future.py5
-rw-r--r--src/python/grpcio/grpc/framework/foundation/logging_pool.py2
-rw-r--r--src/python/grpcio/grpc/framework/foundation/relay.py1
-rw-r--r--src/python/grpcio/grpc/framework/foundation/stream.py4
-rw-r--r--src/python/grpcio/grpc/framework/foundation/stream_util.py3
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/base/base.py23
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/face/face.py43
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/links/links.py5
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py412
-rw-r--r--src/python/grpcio/grpc_version.py2
-rw-r--r--src/python/grpcio/precompiled.py5
-rw-r--r--src/python/grpcio/tests/__init__.py2
-rw-r--r--src/python/grpcio/tests/_loader.py2
-rw-r--r--src/python/grpcio/tests/_result.py8
-rw-r--r--src/python/grpcio/tests/_runner.py105
-rw-r--r--src/python/grpcio/tests/interop/_insecure_interop_test.py2
-rw-r--r--src/python/grpcio/tests/interop/_secure_interop_test.py4
-rw-r--r--src/python/grpcio/tests/interop/client.py4
-rw-r--r--src/python/grpcio/tests/interop/empty.proto43
-rw-r--r--src/python/grpcio/tests/interop/messages.proto167
-rw-r--r--src/python/grpcio/tests/interop/methods.py13
-rw-r--r--src/python/grpcio/tests/interop/server.py2
-rw-r--r--src/python/grpcio/tests/interop/test.proto86
-rw-r--r--src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py52
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py14
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py5
-rw-r--r--src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py4
-rw-r--r--src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py6
-rw-r--r--src/python/grpcio/tests/unit/_links/_proto_scenarios.py5
-rw-r--r--src/python/grpcio/tests/unit/beta/_beta_features_test.py7
-rw-r--r--src/python/grpcio/tests/unit/beta/_face_interface_test.py8
-rw-r--r--src/python/grpcio/tests/unit/beta/_implementations_test.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py4
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_constants.py2
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_control.py6
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_coverage.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/base_util.py6
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py32
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/control.py6
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/coverage.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/digest.py4
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py42
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py45
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/interfaces.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/service.py38
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/test_case.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_control.py20
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py41
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py4
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py54
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_service.py38
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py5
-rw-r--r--src/python/grpcio/tests/unit/test_common.py4
102 files changed, 836 insertions, 1072 deletions
diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst
index 3f4c6fad02..33a462b66f 100644
--- a/src/python/grpcio/README.rst
+++ b/src/python/grpcio/README.rst
@@ -50,10 +50,43 @@ Troubleshooting
Help, I ...
* **... see a** :code:`pkg_resources.VersionConflict` **when I try to install
- grpc!**
+ grpc**
This is likely because :code:`pip` doesn't own the offending dependency,
which in turn is likely because your operating system's package manager owns
it. You'll need to force the installation of the dependency:
:code:`pip install --ignore-installed $OFFENDING_DEPENDENCY`
+
+ For example, if you get an error like the following:
+
+ ::
+
+ Traceback (most recent call last):
+ File "<string>", line 17, in <module>
+ ...
+ File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 509, in find
+ raise VersionConflict(dist, req)
+ pkg_resources.VersionConflict: (six 1.8.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.10'))
+
+ You can fix it by doing:
+
+ ::
+
+ sudo pip install --ignore-installed six
+
+* **... see the following error on some platforms**
+
+ ::
+
+ /tmp/pip-build-U8pSsr/cython/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: No such file or directory
+ #include "Python.h"
+ ^
+ compilation terminated.
+
+ You can fix it by installing `python-dev` package. i.e
+
+ ::
+
+ sudo apt-get install python-dev
+
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index c1f444f6f1..295dab2d27 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,9 @@ from setuptools.command import test
import support
PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))
+GRPC_STEM = os.path.abspath(PYTHON_STEM + '../../../../')
+PROTO_STEM = os.path.join(GRPC_STEM, 'src', 'proto')
+PROTO_GEN_STEM = os.path.join(GRPC_STEM, 'src', 'python', 'gens')
CONF_PY_ADDENDUM = """
extensions.append('sphinx.ext.napoleon')
@@ -157,30 +160,45 @@ class BuildProtoModules(setuptools.Command):
if not self.grpc_python_plugin_command:
raise CommandError('could not find grpc_python_plugin '
'(protoc plugin for GRPC Python)')
+
+ if not os.path.exists(PROTO_GEN_STEM):
+ os.makedirs(PROTO_GEN_STEM)
+
include_regex = re.compile(self.include)
exclude_regex = re.compile(self.exclude) if self.exclude else None
paths = []
- root_directory = PYTHON_STEM
- for walk_root, directories, filenames in os.walk(root_directory):
+ for walk_root, directories, filenames in os.walk(PROTO_STEM):
for filename in filenames:
path = os.path.join(walk_root, filename)
if include_regex.match(path) and not (
exclude_regex and exclude_regex.match(path)):
paths.append(path)
- command = [
- self.protoc_command,
- '--plugin=protoc-gen-python-grpc={}'.format(
- self.grpc_python_plugin_command),
- '-I {}'.format(root_directory),
- '--python_out={}'.format(root_directory),
- '--python-grpc_out={}'.format(root_directory),
- ] + paths
- try:
- subprocess.check_output(' '.join(command), cwd=root_directory, shell=True,
- stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError as e:
- raise CommandError('Command:\n{}\nMessage:\n{}\nOutput:\n{}'.format(
- command, e.message, e.output))
+
+ # TODO(kpayson): It would be nice to do this in a batch command,
+ # but we currently have name conflicts in src/proto
+ for path in paths:
+ command = [
+ self.protoc_command,
+ '--plugin=protoc-gen-python-grpc={}'.format(
+ self.grpc_python_plugin_command),
+ '-I {}'.format(GRPC_STEM),
+ '--python_out={}'.format(PROTO_GEN_STEM),
+ '--python-grpc_out={}'.format(PROTO_GEN_STEM),
+ ] + [path]
+ try:
+ subprocess.check_output(' '.join(command), cwd=PYTHON_STEM, shell=True,
+ stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ sys.stderr.write(
+ 'warning: Command:\n{}\nMessage:\n{}\nOutput:\n{}'.format(
+ command, e.message, e.output))
+
+ # Generated proto directories dont include __init__.py, but
+ # these are needed for python package resolution
+ for walk_root, _, _ in os.walk(PROTO_GEN_STEM):
+ if walk_root != PROTO_GEN_STEM:
+ path = os.path.join(walk_root, '__init__.py')
+ open(path, 'a').close()
class BuildProjectMetadata(setuptools.Command):
@@ -288,15 +306,9 @@ class TestLite(setuptools.Command):
sys.exit('Test failure')
def _add_eggs_to_path(self):
- """Adds all egg files under .eggs to sys.path"""
- # TODO(jtattemusch): there has to be a cleaner way to do this
- import pkg_resources
- eggs_dir = os.path.join(PYTHON_STEM, '../../../.eggs')
- eggs = [os.path.join(eggs_dir, filename)
- for filename in os.listdir(eggs_dir)
- if filename.endswith('.egg')]
- for egg in eggs:
- sys.path.insert(0, pkg_resources.normalize_path(egg))
+ """Fetch install and test requirements"""
+ self.distribution.fetch_build_eggs(self.distribution.install_requires)
+ self.distribution.fetch_build_eggs(self.distribution.tests_require)
class RunInterop(test.test):
diff --git a/src/python/grpcio/grpc/_adapter/_low.py b/src/python/grpcio/grpc/_adapter/_low.py
index 62fd52ab40..b13d8dd9dd 100644
--- a/src/python/grpcio/grpc/_adapter/_low.py
+++ b/src/python/grpcio/grpc/_adapter/_low.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_adapter/_types.py b/src/python/grpcio/grpc/_adapter/_types.py
index 3d5ab33d00..8ca7ff4b60 100644
--- a/src/python/grpcio/grpc/_adapter/_types.py
+++ b/src/python/grpcio/grpc/_adapter/_types.py
@@ -31,6 +31,8 @@ import abc
import collections
import enum
+import six
+
from grpc._cython import cygrpc
@@ -247,8 +249,7 @@ class Event(collections.namedtuple(
"""
-class CompletionQueue:
- __metaclass__ = abc.ABCMeta
+class CompletionQueue(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self):
@@ -262,6 +263,9 @@ class CompletionQueue:
"""
return self
+ def __next__(self):
+ return self.next()
+
@abc.abstractmethod
def next(self, deadline=float('+inf')):
"""Get the next event on this completion queue.
@@ -285,8 +289,7 @@ class CompletionQueue:
return None
-class Call:
- __metaclass__ = abc.ABCMeta
+class Call(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def start_batch(self, ops, tag):
@@ -334,8 +337,7 @@ class Call:
return None
-class Channel:
- __metaclass__ = abc.ABCMeta
+class Channel(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self, target, args, credentials=None):
@@ -399,8 +401,7 @@ class Channel:
return None
-class Server:
- __metaclass__ = abc.ABCMeta
+class Server(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self, completion_queue, args):
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
index d1b9c98ffc..1bfe6344e0 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
index d612c90791..c26bc083cf 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi
index 305475c006..a67c963684 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
index 09e47d4222..cdae39d519 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
index 1d7adca23e..94d13b5999 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -302,6 +302,8 @@ def server_credentials_ssl(pem_root_certs, pem_key_cert_pairs,
(<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair)
credentials.c_credentials = grpc_ssl_server_credentials_create(
c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs,
- credentials.c_ssl_pem_key_cert_pairs_count, force_client_auth, NULL)
+ credentials.c_ssl_pem_key_cert_pairs_count,
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY if force_client_auth else GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ NULL)
return credentials
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
index 61165cb021..3d158a7707 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -105,6 +105,13 @@ cdef extern from "grpc/_cython/loader.h":
GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY
GRPC_SSL_ROOTS_OVERRIDE_FAILED
+ ctypedef enum grpc_ssl_client_certificate_request_type:
+ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY
+ GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+
struct grpc_byte_buffer_reader:
# We don't care about the internals
pass
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
index 851389a261..c2202bdab2 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -254,7 +254,7 @@ cdef class ByteBuffer:
if self.c_byte_buffer != NULL:
with nogil:
grpc_byte_buffer_reader_init(&reader, self.c_byte_buffer)
- result = b""
+ result = bytearray()
with nogil:
while grpc_byte_buffer_reader_next(&reader, &data_slice):
data_slice_pointer = gpr_slice_start_ptr(data_slice)
@@ -263,7 +263,7 @@ cdef class ByteBuffer:
result += (<char *>data_slice_pointer)[:data_slice_length]
with nogil:
grpc_byte_buffer_reader_destroy(&reader)
- return result
+ return bytes(result)
else:
return None
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
index a344230be4..a35eb5ea77 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
index a098f11da2..8419a59068 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pxd b/src/python/grpcio/grpc/_cython/cygrpc.pxd
index 61b0fa788f..9779534e38 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pxd
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pxd
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx
index 8a0f171ee7..8823ea5ef5 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pyx
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.c b/src/python/grpcio/grpc/_cython/imports.generated.c
index 8bd6ae6372..9ab0696702 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.c
+++ b/src/python/grpcio/grpc/_cython/imports.generated.c
@@ -152,6 +152,7 @@ grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_crea
grpc_secure_channel_create_type grpc_secure_channel_create_import;
grpc_server_credentials_release_type grpc_server_credentials_release_import;
grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
+grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
grpc_call_set_credentials_type grpc_call_set_credentials_import;
grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
@@ -174,6 +175,8 @@ grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
gpr_log_type gpr_log_import;
gpr_log_message_type gpr_log_message_import;
+gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
+gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
gpr_set_log_function_type gpr_set_log_function_import;
gpr_slice_ref_type gpr_slice_ref_import;
gpr_slice_unref_type gpr_slice_unref_import;
@@ -418,6 +421,7 @@ void pygrpc_load_imports(HMODULE library) {
grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create");
grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release");
grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create");
+ grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex");
grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port");
grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials");
grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor");
@@ -440,6 +444,8 @@ void pygrpc_load_imports(HMODULE library) {
grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader");
gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log");
gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message");
+ gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity");
+ gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init");
gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function");
gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref");
gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref");
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h
index b70dcccd17..e50051ddc7 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.h
+++ b/src/python/grpcio/grpc/_cython/imports.generated.h
@@ -166,7 +166,7 @@ extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_im
typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name);
extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
-typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level);
+typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);
@@ -283,7 +283,7 @@ extern grpc_call_destroy_type grpc_call_destroy_import;
typedef grpc_call_error(*grpc_server_request_call_type)(grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new);
extern grpc_server_request_call_type grpc_server_request_call_import;
#define grpc_server_request_call grpc_server_request_call_import
-typedef void *(*grpc_server_register_method_type)(grpc_server *server, const char *method, const char *host);
+typedef void *(*grpc_server_register_method_type)(grpc_server *server, const char *method, const char *host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags);
extern grpc_server_register_method_type grpc_server_register_method_import;
#define grpc_server_register_method grpc_server_register_method_import
typedef grpc_call_error(*grpc_server_request_registered_call_type)(grpc_server *server, void *registered_method, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *request_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new);
@@ -406,6 +406,9 @@ extern grpc_server_credentials_release_type grpc_server_credentials_release_impo
typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved);
extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import
+typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_ex_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved);
+extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
+#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import
typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds);
extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
#define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import
@@ -472,6 +475,12 @@ extern gpr_log_type gpr_log_import;
typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message);
extern gpr_log_message_type gpr_log_message_import;
#define gpr_log_message gpr_log_message_import
+typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print);
+extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
+#define gpr_set_log_verbosity gpr_set_log_verbosity_import
+typedef void(*gpr_log_verbosity_init_type)();
+extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
+#define gpr_log_verbosity_init gpr_log_verbosity_init_import
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
diff --git a/src/python/grpcio/grpc/_links/invocation.py b/src/python/grpcio/grpc/_links/invocation.py
index 5ca0a0ee60..003653e1c8 100644
--- a/src/python/grpcio/grpc/_links/invocation.py
+++ b/src/python/grpcio/grpc/_links/invocation.py
@@ -35,6 +35,8 @@ import logging
import threading
import time
+import six
+
from grpc._adapter import _intermediary_low
from grpc._links import _constants
from grpc.beta import interfaces as beta_interfaces
@@ -372,12 +374,11 @@ class _Kernel(object):
pool.shutdown(wait=True)
-class InvocationLink(links.Link, activated.Activated):
+class InvocationLink(six.with_metaclass(abc.ABCMeta, links.Link, activated.Activated)):
"""A links.Link for use on the invocation-side of a gRPC connection.
Implementations of this interface are only valid for use when activated.
"""
- __metaclass__ = abc.ABCMeta
class _InvocationLink(InvocationLink):
diff --git a/src/python/grpcio/grpc/_links/service.py b/src/python/grpcio/grpc/_links/service.py
index 01edee6896..11310e2240 100644
--- a/src/python/grpcio/grpc/_links/service.py
+++ b/src/python/grpcio/grpc/_links/service.py
@@ -177,7 +177,7 @@ class _Kernel(object):
call = service_acceptance.call
call.accept(self._completion_queue, call)
try:
- group, method = service_acceptance.method.split('/')[1:3]
+ group, method = service_acceptance.method.split(b'/')[1:3]
except ValueError:
logging.info('Illegal path "%s"!', service_acceptance.method)
return
diff --git a/src/python/grpcio/grpc/beta/_server.py b/src/python/grpcio/grpc/beta/_server.py
index 2b520cc7e5..eb0aadb42f 100644
--- a/src/python/grpcio/grpc/beta/_server.py
+++ b/src/python/grpcio/grpc/beta/_server.py
@@ -62,7 +62,7 @@ class _GRPCServicer(base.Servicer):
if e.code is None and e.details is None:
raise base.NoSuchMethodError(
interfaces.StatusCode.UNIMPLEMENTED,
- b'Method "%s" of service "%s" not implemented!' % (method, group))
+ 'Method "%s" of service "%s" not implemented!' % (method, group))
else:
raise
diff --git a/src/python/grpcio/grpc/beta/implementations.py b/src/python/grpcio/grpc/beta/implementations.py
index a0ca330d2c..742e94dc65 100644
--- a/src/python/grpcio/grpc/beta/implementations.py
+++ b/src/python/grpcio/grpc/beta/implementations.py
@@ -61,15 +61,16 @@ class ChannelCredentials(object):
self._low_credentials = low_credentials
-def ssl_channel_credentials(root_certificates, private_key, certificate_chain):
+def ssl_channel_credentials(root_certificates=None, private_key=None,
+ certificate_chain=None):
"""Creates a ChannelCredentials for use with an SSL-enabled Channel.
Args:
- root_certificates: The PEM-encoded root certificates or None to ask for
+ root_certificates: The PEM-encoded root certificates or unset to ask for
them to be retrieved from a default location.
- private_key: The PEM-encoded private key to use or None if no private key
+ private_key: The PEM-encoded private key to use or unset if no private key
should be used.
- certificate_chain: The PEM-encoded certificate chain to use or None if no
+ certificate_chain: The PEM-encoded certificate chain to use or unset if no
certificate chain should be used.
Returns:
diff --git a/src/python/grpcio/grpc/beta/interfaces.py b/src/python/grpcio/grpc/beta/interfaces.py
index 0663119163..33ca45ac5b 100644
--- a/src/python/grpcio/grpc/beta/interfaces.py
+++ b/src/python/grpcio/grpc/beta/interfaces.py
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
from grpc._adapter import _types
@@ -105,19 +107,17 @@ def grpc_call_options(disable_compression=False, credentials=None):
return GRPCCallOptions(disable_compression, None, credentials)
-class GRPCAuthMetadataContext(object):
+class GRPCAuthMetadataContext(six.with_metaclass(abc.ABCMeta)):
"""Provides information to call credentials metadata plugins.
Attributes:
service_url: A string URL of the service being called into.
method_name: A string of the fully qualified method name being called.
"""
- __metaclass__ = abc.ABCMeta
-class GRPCAuthMetadataPluginCallback(object):
+class GRPCAuthMetadataPluginCallback(six.with_metaclass(abc.ABCMeta)):
"""Callback object received by a metadata plugin."""
- __metaclass__ = abc.ABCMeta
def __call__(self, metadata, error):
"""Inform the gRPC runtime of the metadata to construct a CallCredentials.
@@ -130,10 +130,9 @@ class GRPCAuthMetadataPluginCallback(object):
raise NotImplementedError()
-class GRPCAuthMetadataPlugin(object):
+class GRPCAuthMetadataPlugin(six.with_metaclass(abc.ABCMeta)):
"""
"""
- __metaclass__ = abc.ABCMeta
def __call__(self, context, callback):
"""Invoke the plugin.
@@ -149,9 +148,8 @@ class GRPCAuthMetadataPlugin(object):
raise NotImplementedError()
-class GRPCServicerContext(object):
+class GRPCServicerContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code servicing RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def peer(self):
@@ -168,9 +166,8 @@ class GRPCServicerContext(object):
raise NotImplementedError()
-class GRPCInvocationContext(object):
+class GRPCInvocationContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code invoking RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def disable_next_request_compression(self):
@@ -178,9 +175,8 @@ class GRPCInvocationContext(object):
raise NotImplementedError()
-class Server(object):
+class Server(six.with_metaclass(abc.ABCMeta)):
"""Services RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_insecure_port(self, address):
diff --git a/src/python/grpcio/grpc/framework/alpha/_face_utilities.py b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
index fb0cfe426d..15c47d5c92 100644
--- a/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
+++ b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
@@ -30,6 +30,8 @@
import abc
import collections
+import six
+
# face_interfaces is referenced from specification in this module.
from grpc.framework.common import cardinality
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
@@ -45,7 +47,7 @@ def _qualified_name(service_name, method_name):
# TODO(nathaniel): This structure is getting bloated; it could be shrunk if
# implementations._Stub used a generic rather than a dynamic underlying
# face-layer stub.
-class InvocationBreakdown(object):
+class InvocationBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of invocation-side views of RPC methods.
Attributes:
@@ -61,7 +63,6 @@ class InvocationBreakdown(object):
to callable behavior to be used deserializing response values for the
RPC.
"""
- __metaclass__ = abc.ABCMeta
class _EasyInvocationBreakdown(
@@ -73,7 +74,7 @@ class _EasyInvocationBreakdown(
pass
-class ServiceBreakdown(object):
+class ServiceBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of service-side views of RPC methods.
Attributes:
@@ -84,7 +85,6 @@ class ServiceBreakdown(object):
response_serializers: A dictionary from service-qualified RPC method name
to callable behavior to be used serializing response values for the RPC.
"""
- __metaclass__ = abc.ABCMeta
class _EasyServiceBreakdown(
@@ -111,7 +111,7 @@ def break_down_invocation(service_name, method_descriptions):
face_cardinalities = {}
request_serializers = {}
response_deserializers = {}
- for name, method_description in method_descriptions.iteritems():
+ for name, method_description in six.iteritems(method_descriptions):
qualified_name = _qualified_name(service_name, name)
method_cardinality = method_description.cardinality()
cardinalities[name] = method_description.cardinality()
@@ -139,7 +139,7 @@ def break_down_service(service_name, method_descriptions):
implementations = {}
request_deserializers = {}
response_serializers = {}
- for name, method_description in method_descriptions.iteritems():
+ for name, method_description in six.iteritems(method_descriptions):
qualified_name = _qualified_name(service_name, name)
method_cardinality = method_description.cardinality()
if method_cardinality is interfaces.Cardinality.UNARY_UNARY:
diff --git a/src/python/grpcio/grpc/framework/alpha/_reexport.py b/src/python/grpcio/grpc/framework/alpha/_reexport.py
index 198cb95ad5..e027077a77 100644
--- a/src/python/grpcio/grpc/framework/alpha/_reexport.py
+++ b/src/python/grpcio/grpc/framework/alpha/_reexport.py
@@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import six
+
from grpc.framework.common import cardinality
from grpc.framework.face import exceptions as face_exceptions
from grpc.framework.face import interfaces as face_interfaces
@@ -181,7 +183,7 @@ def common_cardinality(early_adopter_cardinality):
def common_cardinalities(early_adopter_cardinalities):
common_cardinalities = {}
- for name, early_adopter_cardinality in early_adopter_cardinalities.iteritems():
+ for name, early_adopter_cardinality in six.iteritems(early_adopter_cardinalities):
common_cardinalities[name] = _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[
early_adopter_cardinality]
return common_cardinalities
diff --git a/src/python/grpcio/grpc/framework/alpha/exceptions.py b/src/python/grpcio/grpc/framework/alpha/exceptions.py
index 5234d3b91c..09359c5e94 100644
--- a/src/python/grpcio/grpc/framework/alpha/exceptions.py
+++ b/src/python/grpcio/grpc/framework/alpha/exceptions.py
@@ -31,13 +31,12 @@
Only GRPC should instantiate and raise these exceptions.
"""
-
import abc
+import six
-class RpcError(Exception):
+class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by GRPC."""
- __metaclass__ = abc.ABCMeta
class CancellationError(RpcError):
diff --git a/src/python/grpcio/grpc/framework/alpha/interfaces.py b/src/python/grpcio/grpc/framework/alpha/interfaces.py
index 8380567c97..48f144f614 100644
--- a/src/python/grpcio/grpc/framework/alpha/interfaces.py
+++ b/src/python/grpcio/grpc/framework/alpha/interfaces.py
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
# exceptions is referenced from specification in this module.
from grpc.framework.alpha import exceptions # pylint: disable=unused-import
from grpc.framework.foundation import activated
@@ -59,15 +61,17 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure'
-class CancellableIterator(object):
+class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
"""Returns the self object in accordance with the Iterator protocol."""
raise NotImplementedError()
+ def __next__(self):
+ return self.next()
+
@abc.abstractmethod
def next(self):
"""Returns a value or raises StopIteration per the Iterator protocol."""
@@ -79,9 +83,8 @@ class CancellableIterator(object):
raise NotImplementedError()
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -108,7 +111,7 @@ class RpcContext(object):
raise NotImplementedError()
-class UnaryUnarySyncAsync(object):
+class UnaryUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an
"async" method. Both calls take a request value and a numeric timeout.
@@ -117,7 +120,6 @@ class UnaryUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -147,7 +149,7 @@ class UnaryUnarySyncAsync(object):
raise NotImplementedError()
-class StreamUnarySyncAsync(object):
+class StreamUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an
"async" method. Both calls take an iterator of request values and a numeric
@@ -156,7 +158,6 @@ class StreamUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -191,9 +192,8 @@ class StreamUnarySyncAsync(object):
raise NotImplementedError()
-class RpcMethodDescription(object):
+class RpcMethodDescription(six.with_metaclass(abc.ABCMeta)):
"""A type for the common aspects of RPC method descriptions."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cardinality(self):
@@ -207,9 +207,8 @@ class RpcMethodDescription(object):
raise NotImplementedError()
-class RpcMethodInvocationDescription(RpcMethodDescription):
+class RpcMethodInvocationDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Invocation-side description of an RPC method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def serialize_request(self, request):
@@ -240,9 +239,8 @@ class RpcMethodInvocationDescription(RpcMethodDescription):
raise NotImplementedError()
-class RpcMethodServiceDescription(RpcMethodDescription):
+class RpcMethodServiceDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Service-side description of an RPC method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def deserialize_request(self, serialized_request):
@@ -345,7 +343,7 @@ class RpcMethodServiceDescription(RpcMethodDescription):
raise NotImplementedError()
-class Stub(object):
+class Stub(six.with_metaclass(abc.ABCMeta)):
"""A stub with callable RPC method names for attributes.
Instances of this type are context managers and only afford RPC invocation
@@ -369,12 +367,10 @@ class Stub(object):
exceptions.RpcError, exceptions.CancellationError,
and exceptions.ExpirationError.
"""
- __metaclass__ = abc.ABCMeta
-class Server(activated.Activated):
+class Server(six.with_metaclass(abc.ABCMeta, activated.Activated)):
"""A GRPC Server."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def port(self):
diff --git a/src/python/grpcio/grpc/framework/base/_ingestion.py b/src/python/grpcio/grpc/framework/base/_ingestion.py
index 06d5b92f0b..c9b10acb77 100644
--- a/src/python/grpcio/grpc/framework/base/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/base/_ingestion.py
@@ -32,6 +32,8 @@
import abc
import collections
+import six
+
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import exceptions
@@ -72,9 +74,8 @@ class _EmptyConsumer(stream.Consumer):
"""See stream.Consumer.consume_and_terminate for specification."""
-class _ConsumerCreator(object):
+class _ConsumerCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different consumer-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create_consumer(self, requirement):
diff --git a/src/python/grpcio/grpc/framework/base/_interfaces.py b/src/python/grpcio/grpc/framework/base/_interfaces.py
index d88cf76590..6bb9837c4a 100644
--- a/src/python/grpcio/grpc/framework/base/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/base/_interfaces.py
@@ -31,14 +31,15 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import interfaces # pylint: disable=unused-import
from grpc.framework.foundation import stream
-class TerminationManager(object):
+class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
@@ -91,9 +92,8 @@ class TerminationManager(object):
raise NotImplementedError()
-class TransmissionManager(object):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def inmit(self, emission, complete):
@@ -117,9 +117,8 @@ class TransmissionManager(object):
raise NotImplementedError()
-class EmissionManager(stream.Consumer):
+class EmissionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager of values emitted by customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_manager_and_expiration_manager(
@@ -166,9 +165,8 @@ class EmissionManager(stream.Consumer):
raise NotImplementedError()
-class IngestionManager(stream.Consumer):
+class IngestionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager responsible for executing customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
@@ -214,9 +212,8 @@ class IngestionManager(stream.Consumer):
raise NotImplementedError()
-class ExpirationManager(object):
+class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def change_timeout(self, timeout):
@@ -246,9 +243,8 @@ class ExpirationManager(object):
raise NotImplementedError()
-class ReceptionManager(object):
+class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def receive_ticket(self, ticket):
@@ -261,9 +257,8 @@ class ReceptionManager(object):
raise NotImplementedError()
-class CancellationManager(object):
+class CancellationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of operation cancellation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
diff --git a/src/python/grpcio/grpc/framework/base/_reception.py b/src/python/grpcio/grpc/framework/base/_reception.py
index dd428964f1..a59c5165f9 100644
--- a/src/python/grpcio/grpc/framework/base/_reception.py
+++ b/src/python/grpcio/grpc/framework/base/_reception.py
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.base import interfaces
from grpc.framework.base import _interfaces
@@ -40,9 +42,8 @@ _INITIAL_FRONT_TO_BACK_TICKET_KINDS = (
)
-class _Receiver(object):
+class _Receiver(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-handling behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def abort_if_abortive(self, ticket):
diff --git a/src/python/grpcio/grpc/framework/base/_transmission.py b/src/python/grpcio/grpc/framework/base/_transmission.py
index 6845129234..e2a25626f1 100644
--- a/src/python/grpcio/grpc/framework/base/_transmission.py
+++ b/src/python/grpcio/grpc/framework/base/_transmission.py
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import interfaces
@@ -77,9 +79,8 @@ _ABORTION_OUTCOME_TO_BACK_TO_FRONT_TICKET_KIND = {
}
-class _Ticketizer(object):
+class _Ticketizer(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def ticketize(self, operation_id, sequence_number, payload, complete):
@@ -187,9 +188,8 @@ class _BackTicketizer(_Ticketizer):
operation_id, sequence_number, kind, None)
-class TransmissionManager(_interfaces.TransmissionManager):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta, _interfaces.TransmissionManager)):
"""A _interfaces.TransmissionManager on which other managers may be set."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_and_expiration_managers(
diff --git a/src/python/grpcio/grpc/framework/base/interfaces.py b/src/python/grpcio/grpc/framework/base/interfaces.py
index e22c10d975..995b51cd5b 100644
--- a/src/python/grpcio/grpc/framework/base/interfaces.py
+++ b/src/python/grpcio/grpc/framework/base/interfaces.py
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
# stream is referenced from specification in this module.
from grpc.framework.foundation import stream # pylint: disable=unused-import
@@ -50,13 +52,12 @@ class Outcome(enum.Enum):
SERVICED_FAILURE = 'serviced failure'
-class OperationContext(object):
+class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action.
Attributes:
trace_id: A uuid.UUID identifying a particular set of related operations.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -93,9 +94,8 @@ class OperationContext(object):
raise NotImplementedError()
-class Servicer(object):
+class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, name, context, output_consumer):
@@ -120,7 +120,7 @@ class Servicer(object):
raise NotImplementedError()
-class Operation(object):
+class Operation(six.with_metaclass(abc.ABCMeta)):
"""Representation of an in-progress operation.
Attributes:
@@ -129,7 +129,6 @@ class Operation(object):
context: An OperationContext affording information and action about the
operation.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
@@ -137,9 +136,8 @@ class Operation(object):
raise NotImplementedError()
-class ServicedIngestor(object):
+class ServicedIngestor(six.with_metaclass(abc.ABCMeta)):
"""Responsible for accepting the result of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def consumer(self, operation_context):
@@ -159,7 +157,7 @@ class ServicedIngestor(object):
raise NotImplementedError()
-class ServicedSubscription(object):
+class ServicedSubscription(six.with_metaclass(abc.ABCMeta)):
"""A sum type representing a serviced's interest in an operation.
Attributes:
@@ -167,7 +165,6 @@ class ServicedSubscription(object):
ingestor: A ServicedIngestor. Must be present if kind is Kind.FULL. Must
be None if kind is Kind.TERMINATION_ONLY or Kind.NONE.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
@@ -178,9 +175,8 @@ class ServicedSubscription(object):
NONE = 'none'
-class End(object):
+class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def operation_stats(self):
@@ -202,9 +198,8 @@ class End(object):
raise NotImplementedError()
-class Front(End):
+class Front(six.with_metaclass(abc.ABCMeta, End)):
"""Clientish objects that afford the invocation of operations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def operate(
@@ -228,9 +223,8 @@ class Front(End):
raise NotImplementedError()
-class Back(End):
+class Back(six.with_metaclass(abc.ABCMeta, End)):
"""Serverish objects that perform the work of operations."""
- __metaclass__ = abc.ABCMeta
class FrontToBackTicket(
@@ -315,9 +309,8 @@ class BackToFrontTicket(
TRANSMISSION_FAILURE = 'transmission failure'
-class ForeLink(object):
+class ForeLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts back-to-front tickets and emits front-to-back tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_back_to_front_ticket(self, ticket):
@@ -334,9 +327,8 @@ class ForeLink(object):
raise NotImplementedError()
-class RearLink(object):
+class RearLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts front-to-back tickets and emits back-to-front tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_front_to_back_ticket(self, ticket):
@@ -353,11 +345,9 @@ class RearLink(object):
raise NotImplementedError()
-class FrontLink(Front, ForeLink):
+class FrontLink(six.with_metaclass(abc.ABCMeta, Front, ForeLink)):
"""Clientish objects that operate by sending and receiving tickets."""
- __metaclass__ = abc.ABCMeta
-class BackLink(Back, RearLink):
+class BackLink(six.with_metaclass(abc.ABCMeta, Back, RearLink)):
"""Serverish objects that operate by sending and receiving tickets."""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/core/_end.py b/src/python/grpcio/grpc/framework/core/_end.py
index 9c615672aa..009d27c915 100644
--- a/src/python/grpcio/grpc/framework/core/_end.py
+++ b/src/python/grpcio/grpc/framework/core/_end.py
@@ -33,6 +33,8 @@ import abc
import threading
import uuid
+import six
+
from grpc.framework.core import _operation
from grpc.framework.core import _utilities
from grpc.framework.foundation import callable_util
@@ -45,7 +47,7 @@ from grpc.framework.interfaces.links import utilities
_IDLE_ACTION_EXCEPTION_LOG_MESSAGE = 'Exception calling idle action!'
-class End(base.End, links.Link):
+class End(six.with_metaclass(abc.ABCMeta, base.End, links.Link)):
"""A bridge between base.End and links.Link.
Implementations of this interface translate arriving tickets into
@@ -53,7 +55,6 @@ class End(base.End, links.Link):
translate calls from application objects implementing base interfaces
into tickets sent to a joined link.
"""
- __metaclass__ = abc.ABCMeta
class _Cycle(object):
diff --git a/src/python/grpcio/grpc/framework/core/_ingestion.py b/src/python/grpcio/grpc/framework/core/_ingestion.py
index 4129a8ce43..f2767c981b 100644
--- a/src/python/grpcio/grpc/framework/core/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/core/_ingestion.py
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@@ -70,9 +72,8 @@ class _SubscriptionCreation(
ABANDONED = 'abandoned'
-class _SubscriptionCreator(object):
+class _SubscriptionCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of subscription-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create(self, group, method):
diff --git a/src/python/grpcio/grpc/framework/core/_interfaces.py b/src/python/grpcio/grpc/framework/core/_interfaces.py
index ffa686b2b7..63ac82f80e 100644
--- a/src/python/grpcio/grpc/framework/core/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/core/_interfaces.py
@@ -31,17 +31,18 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base
-class TerminationManager(object):
+class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation.
Attributes:
outcome: None if the operation is active or a base.Outcome value if it has
terminated.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_callback(self, callback):
@@ -105,9 +106,8 @@ class TerminationManager(object):
raise NotImplementedError()
-class TransmissionManager(object):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def kick_off(
@@ -171,9 +171,8 @@ class TransmissionManager(object):
raise NotImplementedError()
-class ExpirationManager(object):
+class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def change_timeout(self, timeout):
@@ -203,9 +202,8 @@ class ExpirationManager(object):
raise NotImplementedError()
-class ProtocolManager(object):
+class ProtocolManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of protocol-specific values passing through an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_protocol_receiver(self, protocol_receiver):
@@ -228,9 +226,8 @@ class ProtocolManager(object):
raise NotImplementedError()
-class EmissionManager(base.Operator):
+class EmissionManager(six.with_metaclass(abc.ABCMeta, base.Operator)):
"""A manager of values emitted by customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def advance(
@@ -254,14 +251,13 @@ class EmissionManager(base.Operator):
raise NotImplementedError()
-class IngestionManager(object):
+class IngestionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for executing customer code.
This name of this manager comes from its responsibility to pass successive
values from the other side of the operation into the code of the local
customer.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_group_and_method(self, group, method):
@@ -294,9 +290,8 @@ class IngestionManager(object):
raise NotImplementedError()
-class ReceptionManager(object):
+class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def receive_ticket(self, ticket):
@@ -308,7 +303,7 @@ class ReceptionManager(object):
raise NotImplementedError()
-class Operation(object):
+class Operation(six.with_metaclass(abc.ABCMeta)):
"""An ongoing operation.
Attributes:
@@ -316,7 +311,6 @@ class Operation(object):
operator: A base.Operator object for the operation for use by the customer
of the operation.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def handle_ticket(self, ticket):
diff --git a/src/python/grpcio/grpc/framework/core/_termination.py b/src/python/grpcio/grpc/framework/core/_termination.py
index 364158b2b8..fff3a3fc14 100644
--- a/src/python/grpcio/grpc/framework/core/_termination.py
+++ b/src/python/grpcio/grpc/framework/core/_termination.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@@ -50,9 +52,8 @@ def _service_completion_predicate(
return transmission_complete and ingestion_complete
-class TerminationManager(_interfaces.TerminationManager):
+class TerminationManager(six.with_metaclass(abc.ABCMeta, _interfaces.TerminationManager)):
"""A _interfaces.TransmissionManager on which another manager may be set."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
diff --git a/src/python/grpcio/grpc/framework/crust/_control.py b/src/python/grpcio/grpc/framework/crust/_control.py
index 5e9efdf732..9b4167bda0 100644
--- a/src/python/grpcio/grpc/framework/crust/_control.py
+++ b/src/python/grpcio/grpc/framework/crust/_control.py
@@ -405,6 +405,9 @@ class Rendezvous(base.Operator, future.Future, stream.Consumer, face.Call):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while True:
diff --git a/src/python/grpcio/grpc/framework/crust/implementations.py b/src/python/grpcio/grpc/framework/crust/implementations.py
index 4ebc4e9ae8..2d3ab733b6 100644
--- a/src/python/grpcio/grpc/framework/crust/implementations.py
+++ b/src/python/grpcio/grpc/framework/crust/implementations.py
@@ -29,6 +29,8 @@
"""Entry points into the Crust layer of RPC Framework."""
+import six
+
from grpc.framework.common import cardinality
from grpc.framework.common import style
from grpc.framework.crust import _calls
@@ -271,7 +273,7 @@ class _DynamicStub(face.DynamicStub):
def _adapt_method_implementations(method_implementations, pool):
adapted_implementations = {}
- for name, method_implementation in method_implementations.iteritems():
+ for name, method_implementation in six.iteritems(method_implementations):
if method_implementation.style is style.Service.INLINE:
if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
adapted_implementations[name] = _service.adapt_inline_unary_unary(
diff --git a/src/python/grpcio/grpc/framework/face/_control.py b/src/python/grpcio/grpc/framework/face/_control.py
index e918907b74..539615efa1 100644
--- a/src/python/grpcio/grpc/framework/face/_control.py
+++ b/src/python/grpcio/grpc/framework/face/_control.py
@@ -120,6 +120,9 @@ class Rendezvous(stream.Consumer):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while ((self._abortion is None) and
diff --git a/src/python/grpcio/grpc/framework/face/exceptions.py b/src/python/grpcio/grpc/framework/face/exceptions.py
index f112df70bc..f95455604d 100644
--- a/src/python/grpcio/grpc/framework/face/exceptions.py
+++ b/src/python/grpcio/grpc/framework/face/exceptions.py
@@ -31,6 +31,8 @@
import abc
+import six
+
class NoSuchMethodError(Exception):
"""Raised by customer code to indicate an unrecognized RPC method name.
@@ -49,12 +51,11 @@ class NoSuchMethodError(Exception):
self.name = name
-class RpcError(Exception):
+class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by the Face layer.
Only RPC Framework should instantiate and raise these exceptions.
"""
- __metaclass__ = abc.ABCMeta
class CancellationError(RpcError):
diff --git a/src/python/grpcio/grpc/framework/face/implementations.py b/src/python/grpcio/grpc/framework/face/implementations.py
index 4a6de52974..96055b4130 100644
--- a/src/python/grpcio/grpc/framework/face/implementations.py
+++ b/src/python/grpcio/grpc/framework/face/implementations.py
@@ -29,6 +29,8 @@
"""Entry points into the Face layer of RPC Framework."""
+import six
+
from grpc.framework.common import cardinality
from grpc.framework.common import style
from grpc.framework.base import exceptions as _base_exceptions
@@ -228,7 +230,7 @@ class _DynamicStub(interfaces.DynamicStub):
def _adapt_method_implementations(method_implementations, pool):
adapted_implementations = {}
- for name, method_implementation in method_implementations.iteritems():
+ for name, method_implementation in six.iteritems(method_implementations):
if method_implementation.style is style.Service.INLINE:
if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
adapted_implementations[name] = _service.adapt_inline_value_in_value_out(
diff --git a/src/python/grpcio/grpc/framework/face/interfaces.py b/src/python/grpcio/grpc/framework/face/interfaces.py
index b7cc4c1169..e9a25c17e1 100644
--- a/src/python/grpcio/grpc/framework/face/interfaces.py
+++ b/src/python/grpcio/grpc/framework/face/interfaces.py
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
# cardinality, style, exceptions, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -52,15 +54,17 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure'
-class CancellableIterator(object):
+class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
"""Returns the self object in accordance with the Iterator protocol."""
raise NotImplementedError()
+ def __next__(self):
+ return self.next()
+
@abc.abstractmethod
def next(self):
"""Returns a value or raises StopIteration per the Iterator protocol."""
@@ -72,9 +76,8 @@ class CancellableIterator(object):
raise NotImplementedError()
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -103,13 +106,12 @@ class RpcContext(object):
raise NotImplementedError()
-class Call(object):
+class Call(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side representation of an RPC.
Attributes:
context: An RpcContext affording information about the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
@@ -117,9 +119,8 @@ class Call(object):
raise NotImplementedError()
-class UnaryUnaryMultiCallable(object):
+class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -171,9 +172,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
-class UnaryStreamMultiCallable(object):
+class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -209,9 +209,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
-class StreamUnaryMultiCallable(object):
+class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -264,9 +263,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
-class StreamStreamMultiCallable(object):
+class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -302,7 +300,7 @@ l Args:
raise NotImplementedError()
-class MethodImplementation(object):
+class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes an RPC method implementation.
Attributes:
@@ -347,12 +345,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
- __metaclass__ = abc.ABCMeta
-class MultiMethodImplementation(object):
+class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many RPC methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, name, response_consumer, context):
@@ -381,9 +377,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
-class GenericStub(object):
+class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC methods to callers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_value_in_value_out(self, name, request, timeout):
@@ -622,7 +617,7 @@ class GenericStub(object):
raise NotImplementedError()
-class DynamicStub(object):
+class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""A stub with RPC-method-bound multi-callable attributes.
Instances of this type responsd to attribute access as follows: if the
@@ -637,4 +632,3 @@ class DynamicStub(object):
the attribute will be a StreamStreamMultiCallable with which to invoke the
RPC method.
"""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/foundation/activated.py b/src/python/grpcio/grpc/framework/foundation/activated.py
index 426a71c705..8b8e4f45b5 100644
--- a/src/python/grpcio/grpc/framework/foundation/activated.py
+++ b/src/python/grpcio/grpc/framework/foundation/activated.py
@@ -31,14 +31,14 @@
import abc
+import six
-class Activated(object):
+class Activated(six.with_metaclass(abc.ABCMeta)):
"""Interface for objects that may be started and stopped.
Values implementing this type must also implement the context manager
protocol.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __enter__(self):
diff --git a/src/python/grpcio/grpc/framework/foundation/callable_util.py b/src/python/grpcio/grpc/framework/foundation/callable_util.py
index 32b0751a01..4f029f97bb 100644
--- a/src/python/grpcio/grpc/framework/foundation/callable_util.py
+++ b/src/python/grpcio/grpc/framework/foundation/callable_util.py
@@ -35,8 +35,10 @@ import enum
import functools
import logging
+import six
-class Outcome(object):
+
+class Outcome(six.with_metaclass(abc.ABCMeta)):
"""A sum type describing the outcome of some call.
Attributes:
@@ -47,7 +49,6 @@ class Outcome(object):
exception: The exception raised by the call. Must be present if kind is
Kind.RAISED.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
diff --git a/src/python/grpcio/grpc/framework/foundation/future.py b/src/python/grpcio/grpc/framework/foundation/future.py
index bfc16fc1ea..9210616150 100644
--- a/src/python/grpcio/grpc/framework/foundation/future.py
+++ b/src/python/grpcio/grpc/framework/foundation/future.py
@@ -49,6 +49,8 @@ built-in-but-only-in-3.3-and-later TimeoutError.
import abc
+import six
+
class TimeoutError(Exception):
"""Indicates that a particular call timed out."""
@@ -58,13 +60,12 @@ class CancelledError(Exception):
"""Indicates that the computation underlying a Future was cancelled."""
-class Future(object):
+class Future(six.with_metaclass(abc.ABCMeta)):
"""A representation of a computation in another control flow.
Computations represented by a Future may be yet to be begun, may be ongoing,
or may have already completed.
"""
- __metaclass__ = abc.ABCMeta
# NOTE(nathaniel): This isn't the return type that I would want to have if it
# were up to me. Were this interface being written from scratch, the return
diff --git a/src/python/grpcio/grpc/framework/foundation/logging_pool.py b/src/python/grpcio/grpc/framework/foundation/logging_pool.py
index f82c7f7fba..9b469a1452 100644
--- a/src/python/grpcio/grpc/framework/foundation/logging_pool.py
+++ b/src/python/grpcio/grpc/framework/foundation/logging_pool.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/grpc/framework/foundation/relay.py b/src/python/grpcio/grpc/framework/foundation/relay.py
index 9c23946552..20f41b2738 100644
--- a/src/python/grpcio/grpc/framework/foundation/relay.py
+++ b/src/python/grpcio/grpc/framework/foundation/relay.py
@@ -46,7 +46,6 @@ class Relay(object):
would be no reason to use an implementation of this interface instead of a
thread pool.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_value(self, value):
diff --git a/src/python/grpcio/grpc/framework/foundation/stream.py b/src/python/grpcio/grpc/framework/foundation/stream.py
index 75c0cf145b..ddd6cc496a 100644
--- a/src/python/grpcio/grpc/framework/foundation/stream.py
+++ b/src/python/grpcio/grpc/framework/foundation/stream.py
@@ -31,10 +31,10 @@
import abc
+import six
-class Consumer(object):
+class Consumer(six.with_metaclass(abc.ABCMeta)):
"""Interface for consumers of finite streams of values or objects."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def consume(self, value):
diff --git a/src/python/grpcio/grpc/framework/foundation/stream_util.py b/src/python/grpcio/grpc/framework/foundation/stream_util.py
index 2210e4efcf..a6f234f1fe 100644
--- a/src/python/grpcio/grpc/framework/foundation/stream_util.py
+++ b/src/python/grpcio/grpc/framework/foundation/stream_util.py
@@ -83,6 +83,9 @@ class IterableConsumer(stream.Consumer):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._active and not self._values:
diff --git a/src/python/grpcio/grpc/framework/interfaces/base/base.py b/src/python/grpcio/grpc/framework/interfaces/base/base.py
index a1e70be5e8..a2ddd9c474 100644
--- a/src/python/grpcio/grpc/framework/interfaces/base/base.py
+++ b/src/python/grpcio/grpc/framework/interfaces/base/base.py
@@ -42,6 +42,8 @@ import abc
import enum
import threading # pylint: disable=unused-import
+import six
+
# abandonment is referenced from specification in this module.
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
@@ -95,7 +97,7 @@ class Outcome(object):
REMOTE_FAILURE = 'remote failure'
-class Completion(object):
+class Completion(six.with_metaclass(abc.ABCMeta)):
"""An aggregate of the values exchanged upon operation completion.
Attributes:
@@ -103,12 +105,10 @@ class Completion(object):
code: A code value for the operation.
message: A message value for the operation.
"""
- __metaclass__ = abc.ABCMeta
-class OperationContext(object):
+class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def outcome(self):
@@ -162,9 +162,8 @@ class OperationContext(object):
raise NotImplementedError()
-class Operator(object):
+class Operator(six.with_metaclass(abc.ABCMeta)):
"""An interface through which to participate in an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def advance(
@@ -184,9 +183,8 @@ class Operator(object):
"""
raise NotImplementedError()
-class ProtocolReceiver(object):
+class ProtocolReceiver(six.with_metaclass(abc.ABCMeta)):
"""A means of receiving protocol values during an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def context(self, protocol_context):
@@ -198,7 +196,7 @@ class ProtocolReceiver(object):
raise NotImplementedError()
-class Subscription(object):
+class Subscription(six.with_metaclass(abc.ABCMeta)):
"""Describes customer code's interest in values from the other side.
Attributes:
@@ -216,7 +214,6 @@ class Subscription(object):
become available during the operation. Must be non-None if kind is
Kind.FULL.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
@@ -226,9 +223,8 @@ class Subscription(object):
FULL = 'full'
-class Servicer(object):
+class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, context, output_operator):
@@ -255,9 +251,8 @@ class Servicer(object):
raise NotImplementedError()
-class End(object):
+class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def start(self):
diff --git a/src/python/grpcio/grpc/framework/interfaces/face/face.py b/src/python/grpcio/grpc/framework/interfaces/face/face.py
index 404c3a7937..4826e7fff6 100644
--- a/src/python/grpcio/grpc/framework/interfaces/face/face.py
+++ b/src/python/grpcio/grpc/framework/interfaces/face/face.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
# cardinality, style, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -96,7 +98,7 @@ class Abortion(
REMOTE_FAILURE = 'remote failure'
-class AbortionError(Exception):
+class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for exceptions indicating RPC abortion.
initial_metadata: The initial metadata from the other side of the RPC or
@@ -108,7 +110,6 @@ class AbortionError(Exception):
details: The details value from the other side of the RPC or None if no
details value was received.
"""
- __metaclass__ = abc.ABCMeta
def __init__(self, initial_metadata, terminal_metadata, code, details):
super(AbortionError, self).__init__()
@@ -150,9 +151,8 @@ class RemoteError(AbortionError):
"""Indicates that an RPC has terminated due to a remote defect."""
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -199,9 +199,8 @@ class RpcContext(object):
raise NotImplementedError()
-class Call(RpcContext):
+class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""Invocation-side utility object for an RPC."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self):
@@ -256,9 +255,8 @@ class Call(RpcContext):
raise NotImplementedError()
-class ServicerContext(RpcContext):
+class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""A context object passed to method implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def invocation_metadata(self):
@@ -326,9 +324,8 @@ class ServicerContext(RpcContext):
raise NotImplementedError()
-class ResponseReceiver(object):
+class ResponseReceiver(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side object used to accept the output of an RPC."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self, initial_metadata):
@@ -362,9 +359,8 @@ class ResponseReceiver(object):
raise NotImplementedError()
-class UnaryUnaryMultiCallable(object):
+class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -434,9 +430,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
-class UnaryStreamMultiCallable(object):
+class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout, metadata=None, protocol_options=None):
@@ -480,9 +475,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
-class StreamUnaryMultiCallable(object):
+class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -553,9 +547,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
-class StreamStreamMultiCallable(object):
+class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -600,7 +593,7 @@ class StreamStreamMultiCallable(object):
raise NotImplementedError()
-class MethodImplementation(object):
+class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes a method implementation.
Attributes:
@@ -643,12 +636,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
- __metaclass__ = abc.ABCMeta
-class MultiMethodImplementation(object):
+class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, response_consumer, context):
@@ -678,9 +669,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
-class GenericStub(object):
+class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via generic methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_unary_unary(
@@ -977,7 +967,7 @@ class GenericStub(object):
raise NotImplementedError()
-class DynamicStub(object):
+class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via attributes corresponding to afforded methods.
Instances of this type may be scoped to a single group so that attribute
@@ -993,4 +983,3 @@ class DynamicStub(object):
if the requested attribute is the name of a stream-stream method, the value of
the attribute will be a StreamStreamMultiCallable with which to invoke an RPC.
"""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/interfaces/links/links.py b/src/python/grpcio/grpc/framework/interfaces/links/links.py
index 24f0e3b354..9631b19078 100644
--- a/src/python/grpcio/grpc/framework/interfaces/links/links.py
+++ b/src/python/grpcio/grpc/framework/interfaces/links/links.py
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
class Protocol(collections.namedtuple('Protocol', ('kind', 'value',))):
"""A sum type for handles to a system that transmits tickets.
@@ -123,9 +125,8 @@ class Ticket(
REMOTE_FAILURE = 'remote failure'
-class Link(object):
+class Link(six.with_metaclass(abc.ABCMeta)):
"""Accepts and emits tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_ticket(self, ticket):
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 31e16e0491..c5a0a398b4 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -30,210 +30,215 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!!
CORE_SOURCE_FILES = [
- 'src/core/profiling/basic_timers.c',
- 'src/core/profiling/stap_timers.c',
- 'src/core/support/alloc.c',
- 'src/core/support/avl.c',
- 'src/core/support/backoff.c',
- 'src/core/support/cmdline.c',
- 'src/core/support/cpu_iphone.c',
- 'src/core/support/cpu_linux.c',
- 'src/core/support/cpu_posix.c',
- 'src/core/support/cpu_windows.c',
- 'src/core/support/env_linux.c',
- 'src/core/support/env_posix.c',
- 'src/core/support/env_win32.c',
- 'src/core/support/histogram.c',
- 'src/core/support/host_port.c',
- 'src/core/support/load_file.c',
- 'src/core/support/log.c',
- 'src/core/support/log_android.c',
- 'src/core/support/log_linux.c',
- 'src/core/support/log_posix.c',
- 'src/core/support/log_win32.c',
- 'src/core/support/murmur_hash.c',
- 'src/core/support/slice.c',
- 'src/core/support/slice_buffer.c',
- 'src/core/support/stack_lockfree.c',
- 'src/core/support/string.c',
- 'src/core/support/string_posix.c',
- 'src/core/support/string_win32.c',
- 'src/core/support/subprocess_posix.c',
- 'src/core/support/subprocess_windows.c',
- 'src/core/support/sync.c',
- 'src/core/support/sync_posix.c',
- 'src/core/support/sync_win32.c',
- 'src/core/support/thd.c',
- 'src/core/support/thd_posix.c',
- 'src/core/support/thd_win32.c',
- 'src/core/support/time.c',
- 'src/core/support/time_posix.c',
- 'src/core/support/time_precise.c',
- 'src/core/support/time_win32.c',
- 'src/core/support/tls_pthread.c',
- 'src/core/support/tmpfile_posix.c',
- 'src/core/support/tmpfile_win32.c',
- 'src/core/support/wrap_memcpy.c',
- 'src/core/census/grpc_context.c',
- 'src/core/census/grpc_filter.c',
- 'src/core/channel/channel_args.c',
- 'src/core/channel/channel_stack.c',
- 'src/core/channel/client_channel.c',
- 'src/core/channel/client_uchannel.c',
- 'src/core/channel/compress_filter.c',
- 'src/core/channel/connected_channel.c',
- 'src/core/channel/http_client_filter.c',
- 'src/core/channel/http_server_filter.c',
- 'src/core/channel/subchannel_call_holder.c',
- 'src/core/client_config/client_config.c',
- 'src/core/client_config/connector.c',
- 'src/core/client_config/default_initial_connect_string.c',
- 'src/core/client_config/initial_connect_string.c',
- 'src/core/client_config/lb_policies/load_balancer_api.c',
- 'src/core/client_config/lb_policies/pick_first.c',
- 'src/core/client_config/lb_policies/round_robin.c',
- 'src/core/client_config/lb_policy.c',
- 'src/core/client_config/lb_policy_factory.c',
- 'src/core/client_config/lb_policy_registry.c',
- 'src/core/client_config/resolver.c',
- 'src/core/client_config/resolver_factory.c',
- 'src/core/client_config/resolver_registry.c',
- 'src/core/client_config/resolvers/dns_resolver.c',
- 'src/core/client_config/resolvers/sockaddr_resolver.c',
- 'src/core/client_config/subchannel.c',
- 'src/core/client_config/subchannel_factory.c',
- 'src/core/client_config/subchannel_index.c',
- 'src/core/client_config/uri_parser.c',
- 'src/core/compression/compression_algorithm.c',
- 'src/core/compression/message_compress.c',
- 'src/core/debug/trace.c',
- 'src/core/httpcli/format_request.c',
- 'src/core/httpcli/httpcli.c',
- 'src/core/httpcli/parser.c',
- 'src/core/iomgr/closure.c',
- 'src/core/iomgr/endpoint.c',
- 'src/core/iomgr/endpoint_pair_posix.c',
- 'src/core/iomgr/endpoint_pair_windows.c',
- 'src/core/iomgr/exec_ctx.c',
- 'src/core/iomgr/executor.c',
- 'src/core/iomgr/fd_posix.c',
- 'src/core/iomgr/iocp_windows.c',
- 'src/core/iomgr/iomgr.c',
- 'src/core/iomgr/iomgr_posix.c',
- 'src/core/iomgr/iomgr_windows.c',
- 'src/core/iomgr/pollset_multipoller_with_epoll.c',
- 'src/core/iomgr/pollset_multipoller_with_poll_posix.c',
- 'src/core/iomgr/pollset_posix.c',
- 'src/core/iomgr/pollset_set_posix.c',
- 'src/core/iomgr/pollset_set_windows.c',
- 'src/core/iomgr/pollset_windows.c',
- 'src/core/iomgr/resolve_address_posix.c',
- 'src/core/iomgr/resolve_address_windows.c',
- 'src/core/iomgr/sockaddr_utils.c',
- 'src/core/iomgr/socket_utils_common_posix.c',
- 'src/core/iomgr/socket_utils_linux.c',
- 'src/core/iomgr/socket_utils_posix.c',
- 'src/core/iomgr/socket_windows.c',
- 'src/core/iomgr/tcp_client_posix.c',
- 'src/core/iomgr/tcp_client_windows.c',
- 'src/core/iomgr/tcp_posix.c',
- 'src/core/iomgr/tcp_server_posix.c',
- 'src/core/iomgr/tcp_server_windows.c',
- 'src/core/iomgr/tcp_windows.c',
- 'src/core/iomgr/time_averaged_stats.c',
- 'src/core/iomgr/timer.c',
- 'src/core/iomgr/timer_heap.c',
- 'src/core/iomgr/udp_server.c',
- 'src/core/iomgr/wakeup_fd_eventfd.c',
- 'src/core/iomgr/wakeup_fd_nospecial.c',
- 'src/core/iomgr/wakeup_fd_pipe.c',
- 'src/core/iomgr/wakeup_fd_posix.c',
- 'src/core/iomgr/workqueue_posix.c',
- 'src/core/iomgr/workqueue_windows.c',
- 'src/core/json/json.c',
- 'src/core/json/json_reader.c',
- 'src/core/json/json_string.c',
- 'src/core/json/json_writer.c',
- 'src/core/proto/grpc/lb/v0/load_balancer.pb.c',
- 'src/core/surface/alarm.c',
- 'src/core/surface/api_trace.c',
- 'src/core/surface/byte_buffer.c',
- 'src/core/surface/byte_buffer_reader.c',
- 'src/core/surface/call.c',
- 'src/core/surface/call_details.c',
- 'src/core/surface/call_log_batch.c',
- 'src/core/surface/channel.c',
- 'src/core/surface/channel_connectivity.c',
- 'src/core/surface/channel_create.c',
- 'src/core/surface/channel_ping.c',
- 'src/core/surface/completion_queue.c',
- 'src/core/surface/event_string.c',
- 'src/core/surface/init.c',
- 'src/core/surface/lame_client.c',
- 'src/core/surface/metadata_array.c',
- 'src/core/surface/server.c',
- 'src/core/surface/server_chttp2.c',
- 'src/core/surface/server_create.c',
- 'src/core/surface/validate_metadata.c',
- 'src/core/surface/version.c',
- 'src/core/transport/byte_stream.c',
- 'src/core/transport/chttp2/alpn.c',
- 'src/core/transport/chttp2/bin_encoder.c',
- 'src/core/transport/chttp2/frame_data.c',
- 'src/core/transport/chttp2/frame_goaway.c',
- 'src/core/transport/chttp2/frame_ping.c',
- 'src/core/transport/chttp2/frame_rst_stream.c',
- 'src/core/transport/chttp2/frame_settings.c',
- 'src/core/transport/chttp2/frame_window_update.c',
- 'src/core/transport/chttp2/hpack_encoder.c',
- 'src/core/transport/chttp2/hpack_parser.c',
- 'src/core/transport/chttp2/hpack_table.c',
- 'src/core/transport/chttp2/huffsyms.c',
- 'src/core/transport/chttp2/incoming_metadata.c',
- 'src/core/transport/chttp2/parsing.c',
- 'src/core/transport/chttp2/status_conversion.c',
- 'src/core/transport/chttp2/stream_lists.c',
- 'src/core/transport/chttp2/stream_map.c',
- 'src/core/transport/chttp2/timeout_encoding.c',
- 'src/core/transport/chttp2/varint.c',
- 'src/core/transport/chttp2/writing.c',
- 'src/core/transport/chttp2_transport.c',
- 'src/core/transport/connectivity_state.c',
- 'src/core/transport/metadata.c',
- 'src/core/transport/metadata_batch.c',
- 'src/core/transport/static_metadata.c',
- 'src/core/transport/transport.c',
- 'src/core/transport/transport_op_string.c',
- 'src/core/httpcli/httpcli_security_connector.c',
- 'src/core/security/b64.c',
- 'src/core/security/client_auth_filter.c',
- 'src/core/security/credentials.c',
- 'src/core/security/credentials_metadata.c',
- 'src/core/security/credentials_posix.c',
- 'src/core/security/credentials_win32.c',
- 'src/core/security/google_default_credentials.c',
- 'src/core/security/handshake.c',
- 'src/core/security/json_token.c',
- 'src/core/security/jwt_verifier.c',
- 'src/core/security/secure_endpoint.c',
- 'src/core/security/security_connector.c',
- 'src/core/security/security_context.c',
- 'src/core/security/server_auth_filter.c',
- 'src/core/security/server_secure_chttp2.c',
- 'src/core/surface/init_secure.c',
- 'src/core/surface/secure_channel_create.c',
- 'src/core/tsi/fake_transport_security.c',
- 'src/core/tsi/ssl_transport_security.c',
- 'src/core/tsi/transport_security.c',
- 'src/core/census/context.c',
- 'src/core/census/initialize.c',
- 'src/core/census/mlog.c',
- 'src/core/census/operation.c',
- 'src/core/census/placeholders.c',
- 'src/core/census/tracing.c',
+ 'src/core/lib/profiling/basic_timers.c',
+ 'src/core/lib/profiling/stap_timers.c',
+ 'src/core/lib/support/alloc.c',
+ 'src/core/lib/support/avl.c',
+ 'src/core/lib/support/backoff.c',
+ 'src/core/lib/support/cmdline.c',
+ 'src/core/lib/support/cpu_iphone.c',
+ 'src/core/lib/support/cpu_linux.c',
+ 'src/core/lib/support/cpu_posix.c',
+ 'src/core/lib/support/cpu_windows.c',
+ 'src/core/lib/support/env_linux.c',
+ 'src/core/lib/support/env_posix.c',
+ 'src/core/lib/support/env_win32.c',
+ 'src/core/lib/support/histogram.c',
+ 'src/core/lib/support/host_port.c',
+ 'src/core/lib/support/load_file.c',
+ 'src/core/lib/support/log.c',
+ 'src/core/lib/support/log_android.c',
+ 'src/core/lib/support/log_linux.c',
+ 'src/core/lib/support/log_posix.c',
+ 'src/core/lib/support/log_win32.c',
+ 'src/core/lib/support/murmur_hash.c',
+ 'src/core/lib/support/slice.c',
+ 'src/core/lib/support/slice_buffer.c',
+ 'src/core/lib/support/stack_lockfree.c',
+ 'src/core/lib/support/string.c',
+ 'src/core/lib/support/string_posix.c',
+ 'src/core/lib/support/string_win32.c',
+ 'src/core/lib/support/subprocess_posix.c',
+ 'src/core/lib/support/subprocess_windows.c',
+ 'src/core/lib/support/sync.c',
+ 'src/core/lib/support/sync_posix.c',
+ 'src/core/lib/support/sync_win32.c',
+ 'src/core/lib/support/thd.c',
+ 'src/core/lib/support/thd_posix.c',
+ 'src/core/lib/support/thd_win32.c',
+ 'src/core/lib/support/time.c',
+ 'src/core/lib/support/time_posix.c',
+ 'src/core/lib/support/time_precise.c',
+ 'src/core/lib/support/time_win32.c',
+ 'src/core/lib/support/tls_pthread.c',
+ 'src/core/lib/support/tmpfile_posix.c',
+ 'src/core/lib/support/tmpfile_win32.c',
+ 'src/core/lib/support/wrap_memcpy.c',
+ 'src/core/lib/surface/init.c',
+ 'src/core/lib/channel/channel_args.c',
+ 'src/core/lib/channel/channel_stack.c',
+ 'src/core/lib/channel/channel_stack_builder.c',
+ 'src/core/lib/channel/compress_filter.c',
+ 'src/core/lib/channel/connected_channel.c',
+ 'src/core/lib/channel/http_client_filter.c',
+ 'src/core/lib/channel/http_server_filter.c',
+ 'src/core/lib/compression/compression_algorithm.c',
+ 'src/core/lib/compression/message_compress.c',
+ 'src/core/lib/debug/trace.c',
+ 'src/core/lib/http/format_request.c',
+ 'src/core/lib/http/httpcli.c',
+ 'src/core/lib/http/parser.c',
+ 'src/core/lib/iomgr/closure.c',
+ 'src/core/lib/iomgr/endpoint.c',
+ 'src/core/lib/iomgr/endpoint_pair_posix.c',
+ 'src/core/lib/iomgr/endpoint_pair_windows.c',
+ 'src/core/lib/iomgr/ev_poll_and_epoll_posix.c',
+ 'src/core/lib/iomgr/ev_posix.c',
+ 'src/core/lib/iomgr/exec_ctx.c',
+ 'src/core/lib/iomgr/executor.c',
+ 'src/core/lib/iomgr/iocp_windows.c',
+ 'src/core/lib/iomgr/iomgr.c',
+ 'src/core/lib/iomgr/iomgr_posix.c',
+ 'src/core/lib/iomgr/iomgr_windows.c',
+ 'src/core/lib/iomgr/pollset_set_windows.c',
+ 'src/core/lib/iomgr/pollset_windows.c',
+ 'src/core/lib/iomgr/resolve_address_posix.c',
+ 'src/core/lib/iomgr/resolve_address_windows.c',
+ 'src/core/lib/iomgr/sockaddr_utils.c',
+ 'src/core/lib/iomgr/socket_utils_common_posix.c',
+ 'src/core/lib/iomgr/socket_utils_linux.c',
+ 'src/core/lib/iomgr/socket_utils_posix.c',
+ 'src/core/lib/iomgr/socket_windows.c',
+ 'src/core/lib/iomgr/tcp_client_posix.c',
+ 'src/core/lib/iomgr/tcp_client_windows.c',
+ 'src/core/lib/iomgr/tcp_posix.c',
+ 'src/core/lib/iomgr/tcp_server_posix.c',
+ 'src/core/lib/iomgr/tcp_server_windows.c',
+ 'src/core/lib/iomgr/tcp_windows.c',
+ 'src/core/lib/iomgr/time_averaged_stats.c',
+ 'src/core/lib/iomgr/timer.c',
+ 'src/core/lib/iomgr/timer_heap.c',
+ 'src/core/lib/iomgr/udp_server.c',
+ 'src/core/lib/iomgr/unix_sockets_posix.c',
+ 'src/core/lib/iomgr/unix_sockets_posix_noop.c',
+ 'src/core/lib/iomgr/wakeup_fd_eventfd.c',
+ 'src/core/lib/iomgr/wakeup_fd_nospecial.c',
+ 'src/core/lib/iomgr/wakeup_fd_pipe.c',
+ 'src/core/lib/iomgr/wakeup_fd_posix.c',
+ 'src/core/lib/iomgr/workqueue_posix.c',
+ 'src/core/lib/iomgr/workqueue_windows.c',
+ 'src/core/lib/json/json.c',
+ 'src/core/lib/json/json_reader.c',
+ 'src/core/lib/json/json_string.c',
+ 'src/core/lib/json/json_writer.c',
+ 'src/core/lib/surface/alarm.c',
+ 'src/core/lib/surface/api_trace.c',
+ 'src/core/lib/surface/byte_buffer.c',
+ 'src/core/lib/surface/byte_buffer_reader.c',
+ 'src/core/lib/surface/call.c',
+ 'src/core/lib/surface/call_details.c',
+ 'src/core/lib/surface/call_log_batch.c',
+ 'src/core/lib/surface/channel.c',
+ 'src/core/lib/surface/channel_init.c',
+ 'src/core/lib/surface/channel_ping.c',
+ 'src/core/lib/surface/channel_stack_type.c',
+ 'src/core/lib/surface/completion_queue.c',
+ 'src/core/lib/surface/event_string.c',
+ 'src/core/lib/surface/lame_client.c',
+ 'src/core/lib/surface/metadata_array.c',
+ 'src/core/lib/surface/server.c',
+ 'src/core/lib/surface/validate_metadata.c',
+ 'src/core/lib/surface/version.c',
+ 'src/core/lib/transport/byte_stream.c',
+ 'src/core/lib/transport/connectivity_state.c',
+ 'src/core/lib/transport/metadata.c',
+ 'src/core/lib/transport/metadata_batch.c',
+ 'src/core/lib/transport/static_metadata.c',
+ 'src/core/lib/transport/transport.c',
+ 'src/core/lib/transport/transport_op_string.c',
+ 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
+ 'src/core/ext/transport/chttp2/transport/frame_data.c',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.c',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.c',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.c',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.c',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
+ 'src/core/ext/transport/chttp2/transport/parsing.c',
+ 'src/core/ext/transport/chttp2/transport/status_conversion.c',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.c',
+ 'src/core/ext/transport/chttp2/transport/stream_map.c',
+ 'src/core/ext/transport/chttp2/transport/timeout_encoding.c',
+ 'src/core/ext/transport/chttp2/transport/varint.c',
+ 'src/core/ext/transport/chttp2/transport/writing.c',
+ 'src/core/ext/transport/chttp2/alpn/alpn.c',
+ 'src/core/lib/http/httpcli_security_connector.c',
+ 'src/core/lib/security/b64.c',
+ 'src/core/lib/security/client_auth_filter.c',
+ 'src/core/lib/security/credentials.c',
+ 'src/core/lib/security/credentials_metadata.c',
+ 'src/core/lib/security/credentials_posix.c',
+ 'src/core/lib/security/credentials_win32.c',
+ 'src/core/lib/security/google_default_credentials.c',
+ 'src/core/lib/security/handshake.c',
+ 'src/core/lib/security/json_token.c',
+ 'src/core/lib/security/jwt_verifier.c',
+ 'src/core/lib/security/secure_endpoint.c',
+ 'src/core/lib/security/security_connector.c',
+ 'src/core/lib/security/security_context.c',
+ 'src/core/lib/security/server_auth_filter.c',
+ 'src/core/lib/surface/init_secure.c',
+ 'src/core/lib/tsi/fake_transport_security.c',
+ 'src/core/lib/tsi/ssl_transport_security.c',
+ 'src/core/lib/tsi/transport_security.c',
+ 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
+ 'src/core/ext/client_config/channel_connectivity.c',
+ 'src/core/ext/client_config/client_channel.c',
+ 'src/core/ext/client_config/client_channel_factory.c',
+ 'src/core/ext/client_config/client_config.c',
+ 'src/core/ext/client_config/client_config_plugin.c',
+ 'src/core/ext/client_config/connector.c',
+ 'src/core/ext/client_config/default_initial_connect_string.c',
+ 'src/core/ext/client_config/initial_connect_string.c',
+ 'src/core/ext/client_config/lb_policy.c',
+ 'src/core/ext/client_config/lb_policy_factory.c',
+ 'src/core/ext/client_config/lb_policy_registry.c',
+ 'src/core/ext/client_config/parse_address.c',
+ 'src/core/ext/client_config/resolver.c',
+ 'src/core/ext/client_config/resolver_factory.c',
+ 'src/core/ext/client_config/resolver_registry.c',
+ 'src/core/ext/client_config/subchannel.c',
+ 'src/core/ext/client_config/subchannel_call_holder.c',
+ 'src/core/ext/client_config/subchannel_index.c',
+ 'src/core/ext/client_config/uri_parser.c',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
+ 'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
+ 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
+ 'src/core/ext/lb_policy/pick_first/pick_first.c',
+ 'src/core/ext/lb_policy/round_robin/round_robin.c',
+ 'src/core/ext/resolver/dns/native/dns_resolver.c',
+ 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
+ 'src/core/ext/census/context.c',
+ 'src/core/ext/census/grpc_context.c',
+ 'src/core/ext/census/grpc_filter.c',
+ 'src/core/ext/census/grpc_plugin.c',
+ 'src/core/ext/census/initialize.c',
+ 'src/core/ext/census/mlog.c',
+ 'src/core/ext/census/operation.c',
+ 'src/core/ext/census/placeholders.c',
+ 'src/core/ext/census/tracing.c',
+ 'src/core/plugin_registry/grpc_plugin_registry.c',
'src/boringssl/err_data.c',
'third_party/boringssl/crypto/aes/aes.c',
'third_party/boringssl/crypto/aes/mode_wrappers.c',
@@ -306,6 +311,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/bn/shift.c',
'third_party/boringssl/crypto/bn/sqrt.c',
'third_party/boringssl/crypto/buf/buf.c',
+ 'third_party/boringssl/crypto/bytestring/asn1_compat.c',
'third_party/boringssl/crypto/bytestring/ber.c',
'third_party/boringssl/crypto/bytestring/cbb.c',
'third_party/boringssl/crypto/bytestring/cbs.c',
@@ -329,6 +335,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/cpu-intel.c',
'third_party/boringssl/crypto/crypto.c',
'third_party/boringssl/crypto/curve25519/curve25519.c',
+ 'third_party/boringssl/crypto/curve25519/x25519-x86_64.c',
'third_party/boringssl/crypto/des/des.c',
'third_party/boringssl/crypto/dh/check.c',
'third_party/boringssl/crypto/dh/dh.c',
@@ -520,6 +527,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/ssl/ssl_buffer.c',
'third_party/boringssl/ssl/ssl_cert.c',
'third_party/boringssl/ssl/ssl_cipher.c',
+ 'third_party/boringssl/ssl/ssl_ecdh.c',
'third_party/boringssl/ssl/ssl_file.c',
'third_party/boringssl/ssl/ssl_lib.c',
'third_party/boringssl/ssl/ssl_rsa.c',
diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py
index 75b88cfd61..873b4e2a91 100644
--- a/src/python/grpcio/grpc_version.py
+++ b/src/python/grpcio/grpc_version.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/precompiled.py b/src/python/grpcio/precompiled.py
index d34250b02c..b6aa7fc90e 100644
--- a/src/python/grpcio/precompiled.py
+++ b/src/python/grpcio/precompiled.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -91,6 +91,9 @@ class BuildTaggedExt(setuptools.Command):
def update_setup_arguments(setup_arguments):
+ if not USE_PRECOMPILED_BINARIES:
+ sys.stderr.write('not using precompiled extension')
+ return
url = '{}/{}.so'.format(BINARIES_REPOSITORY, _tagged_ext_name('cygrpc'))
target_path = os.path.join(PYTHON_STEM, 'grpc/_cython/cygrpc.so')
try:
diff --git a/src/python/grpcio/tests/__init__.py b/src/python/grpcio/tests/__init__.py
index b76b3985a1..a70a1b1f1d 100644
--- a/src/python/grpcio/tests/__init__.py
+++ b/src/python/grpcio/tests/__init__.py
@@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from __future__ import absolute_import
+
from tests import _loader
from tests import _runner
diff --git a/src/python/grpcio/tests/_loader.py b/src/python/grpcio/tests/_loader.py
index 6992029b5e..c2f097f6c6 100644
--- a/src/python/grpcio/tests/_loader.py
+++ b/src/python/grpcio/tests/_loader.py
@@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from __future__ import absolute_import
+
import importlib
import pkgutil
import re
diff --git a/src/python/grpcio/tests/_result.py b/src/python/grpcio/tests/_result.py
index 0670be921f..1acec6a9b5 100644
--- a/src/python/grpcio/tests/_result.py
+++ b/src/python/grpcio/tests/_result.py
@@ -27,7 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import cStringIO as StringIO
+from __future__ import absolute_import
+
import collections
import itertools
import traceback
@@ -35,6 +36,7 @@ import unittest
from xml.etree import ElementTree
import coverage
+from six import moves
from tests import _loader
@@ -202,7 +204,7 @@ class AugmentedResult(unittest.TestResult):
"""
case_id = self.id_map(test)
self.cases[case_id] = self.cases[case_id].updated(
- stdout=stdout, stderr=stderr)
+ stdout=stdout.decode(), stderr=stderr.decode())
def augmented_results(self, filter):
"""Convenience method to retrieve filtered case results.
@@ -356,7 +358,7 @@ def _traceback_string(type, value, trace):
Returns:
str: Formatted exception descriptive string.
"""
- buffer = StringIO.StringIO()
+ buffer = moves.cStringIO()
traceback.print_exception(type, value, trace, file=buffer)
return buffer.getvalue()
diff --git a/src/python/grpcio/tests/_runner.py b/src/python/grpcio/tests/_runner.py
index 32a31ce00e..f0718573e2 100644
--- a/src/python/grpcio/tests/_runner.py
+++ b/src/python/grpcio/tests/_runner.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import cStringIO as StringIO
+from __future__ import absolute_import
+
import collections
import fcntl
import multiprocessing
@@ -35,80 +36,59 @@ import os
import select
import signal
import sys
+import tempfile
import threading
import time
import unittest
import uuid
+import six
+from six import moves
+
from tests import _loader
from tests import _result
-# This number needs to be large enough to outpace output on stdout and stderr
-# from the gRPC core, otherwise we could end up in a potential deadlock. This
-# stems from the OS waiting on someone to clear a filled pipe buffer while the
-# GIL is held from a write to stderr from gRPC core, but said someone is in
-# Python code thus necessitating GIL acquisition.
-_READ_BYTES = 2**20
+class CaptureFile(object):
+ """A context-managed file to redirect output to a byte array.
-class CapturePipe(object):
- """A context-manager pipe to redirect output to a byte array.
+ Use by invoking `start` (`__enter__`) and at some point invoking `stop`
+ (`__exit__`). At any point after the initial call to `start` call `output` to
+ get the current redirected output. Note that we don't currently use file
+ locking, so calling `output` between calls to `start` and `stop` may muddle
+ the result (you should only be doing this during a Python-handled interrupt as
+ a last ditch effort to provide output to the user).
Attributes:
- _redirect_fd (int): File descriptor of file to redirect writes from.
+ _redirected_fd (int): File descriptor of file to redirect writes from.
_saved_fd (int): A copy of the original value of the redirected file
descriptor.
- _read_thread (threading.Thread or None): Thread upon which reads through the
- pipe are performed. Only non-None when self is started.
- _read_fd (int or None): File descriptor of the read end of the redirect
- pipe. Only non-None when self is started.
- _write_fd (int or None): File descriptor of the write end of the redirect
- pipe. Only non-None when self is started.
- output (bytearray or None): Redirected output from writes to the redirected
- file descriptor. Only valid during and after self has started.
+ _into_file (TemporaryFile or None): File to which writes are redirected.
+ Only non-None when self is started.
"""
def __init__(self, fd):
- self._redirect_fd = fd
- self._saved_fd = os.dup(self._redirect_fd)
- self._read_thread = None
- self._read_fd = None
- self._write_fd = None
- self.output = None
+ self._redirected_fd = fd
+ self._saved_fd = os.dup(self._redirected_fd)
+ self._into_file = None
+
+ def output(self):
+ """Get all output from the redirected-to file if it exists."""
+ if self._into_file:
+ self._into_file.seek(0)
+ return bytes(self._into_file.read())
+ else:
+ return bytes()
def start(self):
"""Start redirection of writes to the file descriptor."""
- self._read_fd, self._write_fd = os.pipe()
- os.dup2(self._write_fd, self._redirect_fd)
- flags = fcntl.fcntl(self._read_fd, fcntl.F_GETFL)
- fcntl.fcntl(self._read_fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- self._read_thread = threading.Thread(target=self._read)
- # If the user wants to exit from the Python program and hits ctrl-C and the
- # read thread is somehow deadlocked with something else, the Python code may
- # refuse to exit. This prevents that by making the read thread second-class.
- self._read_thread.daemon = True
- self._read_thread.start()
+ self._into_file = tempfile.TemporaryFile()
+ os.dup2(self._into_file.fileno(), self._redirected_fd)
def stop(self):
"""Stop redirection of writes to the file descriptor."""
- os.close(self._write_fd)
- os.dup2(self._saved_fd, self._redirect_fd) # auto-close self._redirect_fd
- self._read_thread.join()
- self._read_thread = None
- # we waited for the read thread to finish, so _read_fd has been read and we
- # can close it.
- os.close(self._read_fd)
-
- def _read(self):
- """Read-thread target for self."""
- self.output = bytearray()
- while True:
- select.select([self._read_fd], [], [])
- read_bytes = os.read(self._read_fd, _READ_BYTES)
- if read_bytes:
- self.output.extend(read_bytes)
- else:
- break
+ # n.b. this dup2 call auto-closes self._redirected_fd
+ os.dup2(self._saved_fd, self._redirected_fd)
def write_bypass(self, value):
"""Bypass the redirection and write directly to the original file.
@@ -116,6 +96,8 @@ class CapturePipe(object):
Arguments:
value (str): What to write to the original file.
"""
+ if six.PY3 and not isinstance(value, six.binary_type):
+ value = bytes(value, 'ascii')
if self._saved_fd is None:
os.write(self._redirect_fd, value)
else:
@@ -167,11 +149,11 @@ class Runner(object):
for case in filtered_cases]
case_id_by_case = dict((augmented_case.case, augmented_case.id)
for augmented_case in augmented_cases)
- result_out = StringIO.StringIO()
+ result_out = moves.cStringIO()
result = _result.TerminalResult(
result_out, id_map=lambda case: case_id_by_case[case])
- stdout_pipe = CapturePipe(sys.stdout.fileno())
- stderr_pipe = CapturePipe(sys.stderr.fileno())
+ stdout_pipe = CaptureFile(sys.stdout.fileno())
+ stderr_pipe = CaptureFile(sys.stderr.fileno())
kill_flag = [False]
def sigint_handler(signal_number, frame):
@@ -182,7 +164,8 @@ class Runner(object):
def fault_handler(signal_number, frame):
stdout_pipe.write_bypass(
'Received fault signal {}\nstdout:\n{}\n\nstderr:{}\n'
- .format(signal_number, stdout_pipe.output, stderr_pipe.output))
+ .format(signal_number, stdout_pipe.output(),
+ stderr_pipe.output()))
os._exit(1)
def check_kill_self():
@@ -191,9 +174,9 @@ class Runner(object):
result.stopTestRun()
stdout_pipe.write_bypass(result_out.getvalue())
stdout_pipe.write_bypass(
- '\ninterrupted stdout:\n{}\n'.format(stdout_pipe.output))
+ '\ninterrupted stdout:\n{}\n'.format(stdout_pipe.output().decode()))
stderr_pipe.write_bypass(
- '\ninterrupted stderr:\n{}\n'.format(stderr_pipe.output))
+ '\ninterrupted stderr:\n{}\n'.format(stderr_pipe.output().decode()))
os._exit(1)
signal.signal(signal.SIGINT, sigint_handler)
signal.signal(signal.SIGSEGV, fault_handler)
@@ -223,7 +206,7 @@ class Runner(object):
# re-raise the exception after forcing the with-block to end
raise
result.set_output(
- augmented_case.case, stdout_pipe.output, stderr_pipe.output)
+ augmented_case.case, stdout_pipe.output(), stderr_pipe.output())
sys.stdout.write(result_out.getvalue())
sys.stdout.flush()
result_out.truncate(0)
@@ -236,7 +219,7 @@ class Runner(object):
sys.stdout.write(result_out.getvalue())
sys.stdout.flush()
signal.signal(signal.SIGINT, signal.SIG_DFL)
- with open('report.xml', 'w') as report_xml_file:
+ with open('report.xml', 'wb') as report_xml_file:
_result.jenkins_junit_xml(result).write(report_xml_file)
return result
diff --git a/src/python/grpcio/tests/interop/_insecure_interop_test.py b/src/python/grpcio/tests/interop/_insecure_interop_test.py
index 00b49aba37..91519b6fba 100644
--- a/src/python/grpcio/tests/interop/_insecure_interop_test.py
+++ b/src/python/grpcio/tests/interop/_insecure_interop_test.py
@@ -32,11 +32,11 @@
import unittest
from grpc.beta import implementations
+from src.proto.grpc.testing import test_pb2
from tests.interop import _interop_test_case
from tests.interop import methods
from tests.interop import server
-from tests.interop import test_pb2
class InsecureInteropTest(
diff --git a/src/python/grpcio/tests/interop/_secure_interop_test.py b/src/python/grpcio/tests/interop/_secure_interop_test.py
index 7e3061133f..c61547b977 100644
--- a/src/python/grpcio/tests/interop/_secure_interop_test.py
+++ b/src/python/grpcio/tests/interop/_secure_interop_test.py
@@ -32,11 +32,11 @@
import unittest
from grpc.beta import implementations
+from src.proto.grpc.testing import test_pb2
from tests.interop import _interop_test_case
from tests.interop import methods
from tests.interop import resources
-from tests.interop import test_pb2
from tests.unit.beta import test_utilities
@@ -56,7 +56,7 @@ class SecureInteropTest(
self.stub = test_pb2.beta_create_TestService_stub(
test_utilities.not_really_secure_channel(
'[::]', port, implementations.ssl_channel_credentials(
- resources.test_root_certificates(), None, None),
+ resources.test_root_certificates()),
_SERVER_HOST_OVERRIDE))
def tearDown(self):
diff --git a/src/python/grpcio/tests/interop/client.py b/src/python/grpcio/tests/interop/client.py
index 573ec2bd71..db29eb4aa7 100644
--- a/src/python/grpcio/tests/interop/client.py
+++ b/src/python/grpcio/tests/interop/client.py
@@ -33,10 +33,10 @@ import argparse
from oauth2client import client as oauth2client_client
from grpc.beta import implementations
+from src.proto.grpc.testing import test_pb2
from tests.interop import methods
from tests.interop import resources
-from tests.interop import test_pb2
from tests.unit.beta import test_utilities
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
@@ -94,7 +94,7 @@ def _stub(args):
channel = test_utilities.not_really_secure_channel(
args.server_host, args.server_port,
- implementations.ssl_channel_credentials(root_certificates, None, None),
+ implementations.ssl_channel_credentials(root_certificates),
args.server_host_override)
stub = test_pb2.beta_create_TestService_stub(
channel, metadata_transformer=metadata_transformer)
diff --git a/src/python/grpcio/tests/interop/empty.proto b/src/python/grpcio/tests/interop/empty.proto
deleted file mode 100644
index 6d0eb937d6..0000000000
--- a/src/python/grpcio/tests/interop/empty.proto
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-syntax = "proto3";
-
-package grpc.testing;
-
-// An empty message that you can re-use to avoid defining duplicated empty
-// messages in your project. A typical example is to use it as argument or the
-// return value of a service API. For instance:
-//
-// service Foo {
-// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { };
-// };
-//
-message Empty {}
diff --git a/src/python/grpcio/tests/interop/messages.proto b/src/python/grpcio/tests/interop/messages.proto
deleted file mode 100644
index 193b6c4171..0000000000
--- a/src/python/grpcio/tests/interop/messages.proto
+++ /dev/null
@@ -1,167 +0,0 @@
-
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Message definitions to be used by integration test service definitions.
-
-syntax = "proto3";
-
-package grpc.testing;
-
-// The type of payload that should be returned.
-enum PayloadType {
- // Compressable text format.
- COMPRESSABLE = 0;
-
- // Uncompressable binary format.
- UNCOMPRESSABLE = 1;
-
- // Randomly chosen from all other formats defined in this enum.
- RANDOM = 2;
-}
-
-// Compression algorithms
-enum CompressionType {
- // No compression
- NONE = 0;
- GZIP = 1;
- DEFLATE = 2;
-}
-
-// A block of data, to simply increase gRPC message size.
-message Payload {
- // The type of data in body.
- PayloadType type = 1;
- // Primary contents of payload.
- bytes body = 2;
-}
-
-// A protobuf representation for grpc status. This is used by test
-// clients to specify a status that the server should attempt to return.
-message EchoStatus {
- int32 code = 1;
- string message = 2;
-}
-
-// Unary request.
-message SimpleRequest {
- // Desired payload type in the response from the server.
- // If response_type is RANDOM, server randomly chooses one from other formats.
- PayloadType response_type = 1;
-
- // Desired payload size in the response from the server.
- // If response_type is COMPRESSABLE, this denotes the size before compression.
- int32 response_size = 2;
-
- // Optional input payload sent along with the request.
- Payload payload = 3;
-
- // Whether SimpleResponse should include username.
- bool fill_username = 4;
-
- // Whether SimpleResponse should include OAuth scope.
- bool fill_oauth_scope = 5;
-
- // Compression algorithm to be used by the server for the response (stream)
- CompressionType response_compression = 6;
-
- // Whether server should return a given status
- EchoStatus response_status = 7;
-}
-
-// Unary response, as configured by the request.
-message SimpleResponse {
- // Payload to increase message size.
- Payload payload = 1;
- // The user the request came from, for verifying authentication was
- // successful when the client expected it.
- string username = 2;
- // OAuth scope.
- string oauth_scope = 3;
-}
-
-// Client-streaming request.
-message StreamingInputCallRequest {
- // Optional input payload sent along with the request.
- Payload payload = 1;
-
- // Not expecting any payload from the response.
-}
-
-// Client-streaming response.
-message StreamingInputCallResponse {
- // Aggregated size of payloads received from the client.
- int32 aggregated_payload_size = 1;
-}
-
-// Configuration for a particular response.
-message ResponseParameters {
- // Desired payload sizes in responses from the server.
- // If response_type is COMPRESSABLE, this denotes the size before compression.
- int32 size = 1;
-
- // Desired interval between consecutive responses in the response stream in
- // microseconds.
- int32 interval_us = 2;
-}
-
-// Server-streaming request.
-message StreamingOutputCallRequest {
- // Desired payload type in the response from the server.
- // If response_type is RANDOM, the payload from each response in the stream
- // might be of different types. This is to simulate a mixed type of payload
- // stream.
- PayloadType response_type = 1;
-
- // Configuration for each expected response message.
- repeated ResponseParameters response_parameters = 2;
-
- // Optional input payload sent along with the request.
- Payload payload = 3;
-
- // Compression algorithm to be used by the server for the response (stream)
- CompressionType response_compression = 6;
-
- // Whether server should return a given status
- EchoStatus response_status = 7;
-}
-
-// Server-streaming response, as configured by the request and parameters.
-message StreamingOutputCallResponse {
- // Payload to increase response size.
- Payload payload = 1;
-}
-
-// For reconnect interop test only.
-// Server tells client whether its reconnects are following the spec and the
-// reconnect backoffs it saw.
-message ReconnectInfo {
- bool passed = 1;
- repeated int32 backoff_ms = 2;
-}
diff --git a/src/python/grpcio/tests/interop/methods.py b/src/python/grpcio/tests/interop/methods.py
index b3591aef7b..67862ed7d3 100644
--- a/src/python/grpcio/tests/interop/methods.py
+++ b/src/python/grpcio/tests/interop/methods.py
@@ -29,6 +29,8 @@
"""Implementations of interoperability test methods."""
+from __future__ import print_function
+
import enum
import json
import os
@@ -40,9 +42,9 @@ from oauth2client import client as oauth2client_client
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import face
-from tests.interop import empty_pb2
-from tests.interop import messages_pb2
-from tests.interop import test_pb2
+from src.proto.grpc.testing import empty_pb2
+from src.proto.grpc.testing import messages_pb2
+from src.proto.grpc.testing import test_pb2
_TIMEOUT = 7
@@ -173,6 +175,9 @@ class _Pipe(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while not self._values and self._open:
@@ -205,7 +210,7 @@ def _ping_pong(stub):
with stub, _Pipe() as pipe:
response_iterator = stub.FullDuplexCall(pipe, _TIMEOUT)
- print 'Starting ping-pong with response iterator %s' % response_iterator
+ print('Starting ping-pong with response iterator %s' % response_iterator)
for response_size, payload_size in zip(
request_response_sizes, request_payload_sizes):
request = messages_pb2.StreamingOutputCallRequest(
diff --git a/src/python/grpcio/tests/interop/server.py b/src/python/grpcio/tests/interop/server.py
index 6dd55f008c..ab2c3c708f 100644
--- a/src/python/grpcio/tests/interop/server.py
+++ b/src/python/grpcio/tests/interop/server.py
@@ -34,10 +34,10 @@ import logging
import time
from grpc.beta import implementations
+from src.proto.grpc.testing import test_pb2
from tests.interop import methods
from tests.interop import resources
-from tests.interop import test_pb2
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
diff --git a/src/python/grpcio/tests/interop/test.proto b/src/python/grpcio/tests/interop/test.proto
deleted file mode 100644
index 9feecc0278..0000000000
--- a/src/python/grpcio/tests/interop/test.proto
+++ /dev/null
@@ -1,86 +0,0 @@
-
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// An integration test service that covers all the method signature permutations
-// of unary/streaming requests/responses.
-
-syntax = "proto3";
-
-import "tests/interop/empty.proto";
-import "tests/interop/messages.proto";
-
-package grpc.testing;
-
-// A simple service to test the various types of RPCs and experiment with
-// performance with various types of payload.
-service TestService {
- // One empty request followed by one empty response.
- rpc EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty);
-
- // One request followed by one response.
- rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
-
- // One request followed by a sequence of responses (streamed download).
- // The server returns the payload with client desired type and sizes.
- rpc StreamingOutputCall(StreamingOutputCallRequest)
- returns (stream StreamingOutputCallResponse);
-
- // A sequence of requests followed by one response (streamed upload).
- // The server returns the aggregated size of client payload as the result.
- rpc StreamingInputCall(stream StreamingInputCallRequest)
- returns (StreamingInputCallResponse);
-
- // A sequence of requests with each request served by the server immediately.
- // As one request could lead to multiple responses, this interface
- // demonstrates the idea of full duplexing.
- rpc FullDuplexCall(stream StreamingOutputCallRequest)
- returns (stream StreamingOutputCallResponse);
-
- // A sequence of requests followed by a sequence of responses.
- // The server buffers all the client requests and then serves them in order. A
- // stream of responses are returned to the client when the server starts with
- // first request.
- rpc HalfDuplexCall(stream StreamingOutputCallRequest)
- returns (stream StreamingOutputCallResponse);
-}
-
-
-// A simple service NOT implemented at servers so clients can test for
-// that case.
-service UnimplementedService {
- // A call that no server should implement
- rpc UnimplementedCall(grpc.testing.Empty) returns(grpc.testing.Empty);
-}
-
-// A service used to control reconnect server.
-service ReconnectService {
- rpc Start(grpc.testing.Empty) returns (grpc.testing.Empty);
- rpc Stop(grpc.testing.Empty) returns (grpc.testing.ReconnectInfo);
-}
diff --git a/src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py b/src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py
index ba5b219a88..6fba3d4271 100644
--- a/src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py
+++ b/src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py
@@ -42,6 +42,8 @@ import threading
import time
import unittest
+from six import moves
+
from grpc.beta import implementations
from grpc.framework.foundation import future
from grpc.framework.interfaces.face import face
@@ -250,7 +252,7 @@ class PythonPluginTest(unittest.TestCase):
def testImportAttributes(self):
# check that we can access the generated module and its members.
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
self.assertIsNotNone(getattr(test_pb2, SERVICER_IDENTIFIER, None))
self.assertIsNotNone(getattr(test_pb2, STUB_IDENTIFIER, None))
self.assertIsNotNone(getattr(test_pb2, SERVER_FACTORY_IDENTIFIER, None))
@@ -258,13 +260,13 @@ class PythonPluginTest(unittest.TestCase):
def testUpDown(self):
import protoc_plugin_test_pb2 as test_pb2
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (servicer, stub):
request = test_pb2.SimpleRequest(response_size=13)
def testUnaryCall(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
request = test_pb2.SimpleRequest(response_size=13)
response = stub.UnaryCall(request, test_constants.LONG_TIMEOUT)
@@ -273,7 +275,7 @@ class PythonPluginTest(unittest.TestCase):
def testUnaryCallFuture(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = test_pb2.SimpleRequest(response_size=13)
with _CreateService(test_pb2) as (methods, stub):
# Check that the call does not block waiting for the server to respond.
@@ -286,7 +288,7 @@ class PythonPluginTest(unittest.TestCase):
def testUnaryCallFutureExpired(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
request = test_pb2.SimpleRequest(response_size=13)
with methods.pause():
@@ -297,7 +299,7 @@ class PythonPluginTest(unittest.TestCase):
def testUnaryCallFutureCancelled(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = test_pb2.SimpleRequest(response_size=13)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
@@ -307,7 +309,7 @@ class PythonPluginTest(unittest.TestCase):
def testUnaryCallFutureFailed(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = test_pb2.SimpleRequest(response_size=13)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
@@ -317,20 +319,20 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingOutputCall(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
responses = stub.StreamingOutputCall(
request, test_constants.LONG_TIMEOUT)
expected_responses = methods.StreamingOutputCall(
request, 'not a real RpcContext!')
- for expected_response, response in itertools.izip_longest(
+ for expected_response, response in moves.zip_longest(
expected_responses, responses):
self.assertEqual(expected_response, response)
def testStreamingOutputCallExpired(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
@@ -341,7 +343,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingOutputCallCancelled(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (unused_methods, stub):
responses = stub.StreamingOutputCall(
@@ -353,7 +355,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingOutputCallFailed(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
@@ -364,7 +366,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingInputCall(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
response = stub.StreamingInputCall(
_streaming_input_request_iterator(test_pb2),
@@ -375,7 +377,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingInputCallFuture(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
response_future = stub.StreamingInputCall.future(
@@ -388,7 +390,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingInputCallFutureExpired(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
response_future = stub.StreamingInputCall.future(
@@ -401,7 +403,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingInputCallFutureCancelled(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
response_future = stub.StreamingInputCall.future(
@@ -414,7 +416,7 @@ class PythonPluginTest(unittest.TestCase):
def testStreamingInputCallFutureFailed(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
response_future = stub.StreamingInputCall.future(
@@ -424,19 +426,19 @@ class PythonPluginTest(unittest.TestCase):
def testFullDuplexCall(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
responses = stub.FullDuplexCall(
_full_duplex_request_iterator(test_pb2), test_constants.LONG_TIMEOUT)
expected_responses = methods.FullDuplexCall(
_full_duplex_request_iterator(test_pb2), 'not a real RpcContext!')
- for expected_response, response in itertools.izip_longest(
+ for expected_response, response in moves.zip_longest(
expected_responses, responses):
self.assertEqual(expected_response, response)
def testFullDuplexCallExpired(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request_iterator = _full_duplex_request_iterator(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
@@ -447,7 +449,7 @@ class PythonPluginTest(unittest.TestCase):
def testFullDuplexCallCancelled(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
request_iterator = _full_duplex_request_iterator(test_pb2)
responses = stub.FullDuplexCall(
@@ -459,7 +461,7 @@ class PythonPluginTest(unittest.TestCase):
def testFullDuplexCallFailed(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
request_iterator = _full_duplex_request_iterator(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
@@ -471,7 +473,7 @@ class PythonPluginTest(unittest.TestCase):
def testHalfDuplexCall(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
def half_duplex_request_iterator():
request = test_pb2.StreamingOutputCallRequest()
@@ -485,13 +487,13 @@ class PythonPluginTest(unittest.TestCase):
half_duplex_request_iterator(), test_constants.LONG_TIMEOUT)
expected_responses = methods.HalfDuplexCall(
half_duplex_request_iterator(), 'not a real RpcContext!')
- for check in itertools.izip_longest(expected_responses, responses):
+ for check in moves.zip_longest(expected_responses, responses):
expected_response, response = check
self.assertEqual(expected_response, response)
def testHalfDuplexCallWedged(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
- reload(test_pb2)
+ moves.reload_module(test_pb2)
condition = threading.Condition()
wait_cell = [False]
@contextlib.contextmanager
diff --git a/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py b/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py
index a6fd82388c..22d4b019c7 100644
--- a/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py
+++ b/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py
@@ -29,11 +29,13 @@
"""Tests for the old '_low'."""
-import Queue
import threading
import time
import unittest
+import six
+from six.moves import queue
+
from grpc._adapter import _intermediary_low as _low
_STREAM_LENGTH = 300
@@ -67,7 +69,7 @@ class LonelyClientTest(unittest.TestCase):
second_event = completion_queue.get(after_deadline)
self.assertIsNotNone(second_event)
kinds = [event.kind for event in (first_event, second_event)]
- self.assertItemsEqual(
+ six.assertCountEqual(self,
(_low.Event.Kind.METADATA_ACCEPTED, _low.Event.Kind.FINISH),
kinds)
@@ -99,7 +101,7 @@ class EchoTest(unittest.TestCase):
self.server = _low.Server(self.server_completion_queue)
port = self.server.add_http2_addr('[::]:0')
self.server.start()
- self.server_events = Queue.Queue()
+ self.server_events = queue.Queue()
self.server_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.server_completion_queue, self.server_events))
@@ -107,7 +109,7 @@ class EchoTest(unittest.TestCase):
self.client_completion_queue = _low.CompletionQueue()
self.channel = _low.Channel('%s:%d' % (self.host, port), None)
- self.client_events = Queue.Queue()
+ self.client_events = queue.Queue()
self.client_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.client_completion_queue, self.client_events))
@@ -315,7 +317,7 @@ class CancellationTest(unittest.TestCase):
self.server = _low.Server(self.server_completion_queue)
port = self.server.add_http2_addr('[::]:0')
self.server.start()
- self.server_events = Queue.Queue()
+ self.server_events = queue.Queue()
self.server_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.server_completion_queue, self.server_events))
@@ -323,7 +325,7 @@ class CancellationTest(unittest.TestCase):
self.client_completion_queue = _low.CompletionQueue()
self.channel = _low.Channel('%s:%d' % (self.host, port), None)
- self.client_events = Queue.Queue()
+ self.client_events = queue.Queue()
self.client_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.client_completion_queue, self.client_events))
diff --git a/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
index f55a7a23ea..7a90eacf77 100644
--- a/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
@@ -32,12 +32,13 @@
import abc
import threading
+import six
+
from tests.unit._junkdrawer import math_pb2
-class ProtoScenario(object):
+class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def method(self):
diff --git a/src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py b/src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
index efc990421a..2b8981c752 100644
--- a/src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
+++ b/src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
@@ -35,6 +35,8 @@ import random
import time
import unittest
+import six
+
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
@@ -68,7 +70,7 @@ def _serialization_behaviors_from_serializations(serializations):
request_deserializers = {}
response_serializers = {}
response_deserializers = {}
- for (group, method), serialization in serializations.iteritems():
+ for (group, method), serialization in six.iteritems(serializations):
request_serializers[group, method] = serialization.serialize_request
request_deserializers[group, method] = serialization.deserialize_request
response_serializers[group, method] = serialization.serialize_response
diff --git a/src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py b/src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
index 4faaaadc2b..50b9a5a824 100644
--- a/src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
+++ b/src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
@@ -32,6 +32,8 @@
import collections
import unittest
+import six
+
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
@@ -59,7 +61,7 @@ def _serialization_behaviors_from_test_methods(test_methods):
request_deserializers = {}
response_serializers = {}
response_deserializers = {}
- for (group, method), test_method in test_methods.iteritems():
+ for (group, method), test_method in six.iteritems(test_methods):
request_serializers[group, method] = test_method.serialize_request
request_deserializers[group, method] = test_method.deserialize_request
response_serializers[group, method] = test_method.serialize_response
@@ -108,7 +110,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest.
cardinalities = {
method: method_object.cardinality()
- for (group, method), method_object in methods.iteritems()}
+ for (group, method), method_object in six.iteritems(methods)}
dynamic_stub = crust_implementations.dynamic_stub(
invocation_end_link, group, cardinalities, pool)
diff --git a/src/python/grpcio/tests/unit/_links/_proto_scenarios.py b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
index f69ff51b16..50661085f9 100644
--- a/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
@@ -32,13 +32,14 @@
import abc
import threading
+import six
+
from tests.unit._junkdrawer import math_pb2
from tests.unit.framework.common import test_constants
-class ProtoScenario(object):
+class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group_and_method(self):
diff --git a/src/python/grpcio/tests/unit/beta/_beta_features_test.py b/src/python/grpcio/tests/unit/beta/_beta_features_test.py
index ea44177b49..bb2893a21b 100644
--- a/src/python/grpcio/tests/unit/beta/_beta_features_test.py
+++ b/src/python/grpcio/tests/unit/beta/_beta_features_test.py
@@ -125,6 +125,9 @@ class _BlockingIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while True:
@@ -180,7 +183,7 @@ class BetaFeaturesTest(unittest.TestCase):
port = self._server.add_secure_port('[::]:0', server_credentials)
self._server.start()
self._channel_credentials = implementations.ssl_channel_credentials(
- resources.test_root_certificates(), None, None)
+ resources.test_root_certificates())
self._call_credentials = implementations.metadata_call_credentials(
_metadata_plugin)
channel = test_utilities.not_really_secure_channel(
@@ -293,7 +296,7 @@ class ContextManagementAndLifecycleTest(unittest.TestCase):
self._server_credentials = implementations.ssl_server_credentials(
[(resources.private_key(), resources.certificate_chain(),),])
self._channel_credentials = implementations.ssl_channel_credentials(
- resources.test_root_certificates(), None, None)
+ resources.test_root_certificates())
self._stub_options = implementations.stub_options(
thread_pool_size=test_constants.POOL_SIZE)
diff --git a/src/python/grpcio/tests/unit/beta/_face_interface_test.py b/src/python/grpcio/tests/unit/beta/_face_interface_test.py
index 1c21dfd03d..3a67516906 100644
--- a/src/python/grpcio/tests/unit/beta/_face_interface_test.py
+++ b/src/python/grpcio/tests/unit/beta/_face_interface_test.py
@@ -32,6 +32,8 @@
import collections
import unittest
+import six
+
from grpc.beta import implementations
from grpc.beta import interfaces
from tests.unit import resources
@@ -57,7 +59,7 @@ def _serialization_behaviors_from_test_methods(test_methods):
request_deserializers = {}
response_serializers = {}
response_deserializers = {}
- for (group, method), test_method in test_methods.iteritems():
+ for (group, method), test_method in six.iteritems(test_methods):
request_serializers[group, method] = test_method.serialize_request
request_deserializers[group, method] = test_method.deserialize_request
response_serializers[group, method] = test_method.serialize_response
@@ -79,7 +81,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest.
cardinalities = {
method: method_object.cardinality()
- for (group, method), method_object in methods.iteritems()}
+ for (group, method), method_object in six.iteritems(methods)}
server_options = implementations.server_options(
request_deserializers=serialization_behaviors.request_deserializers,
@@ -92,7 +94,7 @@ class _Implementation(test_interfaces.Implementation):
port = server.add_secure_port('[::]:0', server_credentials)
server.start()
channel_credentials = implementations.ssl_channel_credentials(
- resources.test_root_certificates(), None, None)
+ resources.test_root_certificates())
channel = test_utilities.not_really_secure_channel(
'localhost', port, channel_credentials, _SERVER_HOST_OVERRIDE)
stub_options = implementations.stub_options(
diff --git a/src/python/grpcio/tests/unit/beta/_implementations_test.py b/src/python/grpcio/tests/unit/beta/_implementations_test.py
index 6b32305af7..26be670c45 100644
--- a/src/python/grpcio/tests/unit/beta/_implementations_test.py
+++ b/src/python/grpcio/tests/unit/beta/_implementations_test.py
@@ -38,14 +38,13 @@ from tests.unit import resources
class ChannelCredentialsTest(unittest.TestCase):
def test_runtime_provided_root_certificates(self):
- channel_credentials = implementations.ssl_channel_credentials(
- None, None, None)
+ channel_credentials = implementations.ssl_channel_credentials()
self.assertIsInstance(
channel_credentials, implementations.ChannelCredentials)
def test_application_provided_root_certificates(self):
channel_credentials = implementations.ssl_channel_credentials(
- resources.test_root_certificates(), None, None)
+ resources.test_root_certificates())
self.assertIsInstance(
channel_credentials, implementations.ChannelCredentials)
diff --git a/src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py b/src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
index 360ecc95d5..43457be362 100644
--- a/src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
+++ b/src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
@@ -32,6 +32,8 @@
import collections
import unittest
+import six
+
from grpc.framework.core import implementations as core_implementations
from grpc.framework.crust import implementations as crust_implementations
from grpc.framework.foundation import logging_pool
@@ -66,7 +68,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest.
cardinalities = {
method: method_object.cardinality()
- for (group, method), method_object in methods.iteritems()}
+ for (group, method), method_object in six.iteritems(methods)}
dynamic_stub = crust_implementations.dynamic_stub(
invocation_end_link, group, cardinalities, pool)
diff --git a/src/python/grpcio/tests/unit/framework/common/test_constants.py b/src/python/grpcio/tests/unit/framework/common/test_constants.py
index 9f1fb8471c..8d89101e09 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_constants.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_constants.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/tests/unit/framework/common/test_control.py b/src/python/grpcio/tests/unit/framework/common/test_control.py
index 8d6eba5c2c..ca5ba3a854 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_control.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_control.py
@@ -33,6 +33,8 @@ import abc
import contextlib
import threading
+import six
+
class Defect(Exception):
"""Simulates a programming defect raised into in a system under test.
@@ -42,7 +44,7 @@ class Defect(Exception):
"""
-class Control(object):
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -51,8 +53,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/common/test_coverage.py b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
index a7ed3582c4..ea2d2812ce 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_coverage.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
@@ -31,13 +31,14 @@
import abc
+import six
+
# This code is designed for use with the unittest module.
# pylint: disable=invalid-name
-class Coverage(object):
+class Coverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
index 1df1529b27..59652b3e90 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
@@ -31,6 +31,8 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import util as _base_util
from grpc.framework.base import implementations
@@ -43,7 +45,7 @@ _POOL_SIZE_LIMIT = 5
_MAXIMUM_TIMEOUT = 90
-class LinkedPair(object):
+class LinkedPair(six.with_metaclass(abc.ABCMeta)):
"""A Front and Back that are linked to one another.
Attributes:
@@ -51,8 +53,6 @@ class LinkedPair(object):
back: An interfaces.Back.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def shut_down(self):
"""Shuts down this object and releases its resources."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
index 0613516421..2ebe1a32a4 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.face import exceptions
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import control
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class BlockingInvocationInlineServiceTestCase(
- test_case.FaceTestCase, coverage.BlockingCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.BlockingCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
@@ -72,7 +74,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -83,7 +85,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -95,7 +97,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -106,7 +108,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -118,7 +120,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSequentialInvocations(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -135,7 +137,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -146,7 +148,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -158,7 +160,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -169,7 +171,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -181,7 +183,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -191,7 +193,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -202,7 +204,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -212,7 +214,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/control.py b/src/python/grpcio/tests/unit/framework/face/testing/control.py
index 3960c4e649..8425affcc9 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/control.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/control.py
@@ -33,8 +33,10 @@ import abc
import contextlib
import threading
+import six
-class Control(object):
+
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -43,8 +45,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
index f3aca113fe..3c88b7841a 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
@@ -31,15 +31,15 @@
import abc
+import six
+
# These classes are only valid when inherited by unittest.TestCases.
# pylint: disable=invalid-name
-class BlockingCoverage(object):
+class BlockingCoverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage for blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
raise NotImplementedError()
@@ -93,11 +93,9 @@ class BlockingCoverage(object):
raise NotImplementedError()
-class FullCoverage(BlockingCoverage):
+class FullCoverage(six.with_metaclass(abc.ABCMeta, BlockingCoverage)):
"""Specification of test coverage for non-blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testParallelInvocations(self):
raise NotImplementedError()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/digest.py b/src/python/grpcio/tests/unit/framework/face/testing/digest.py
index 39f28b9657..2b45aded20 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/digest.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/digest.py
@@ -32,6 +32,8 @@
import collections
import threading
+import six
+
# testing_control, interfaces, and testing_service are referenced from
# specification in this module.
from grpc.framework.common import cardinality
@@ -368,7 +370,7 @@ def _assemble(
events = {}
adaptations = {}
messages = {}
- for name, scenario in scenarios.iteritems():
+ for name, scenario in six.iteritems(scenarios):
if name in names:
raise ValueError('Repeated name "%s"!' % name)
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
index 179f3a2f67..98b61e492c 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
@@ -32,6 +32,8 @@
import abc
import unittest
+import six
+
from grpc.framework.face import interfaces
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import callback as testing_callback
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class EventInvocationSynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
@@ -72,7 +74,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -87,7 +89,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -102,7 +104,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@@ -120,7 +122,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@@ -138,7 +140,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSequentialInvocations(self):
# pylint: disable=cell-var-from-loop
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -163,7 +165,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -178,7 +180,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -193,7 +195,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for unused_test_messages in test_messages_sequence:
callback = testing_callback.Callback()
@@ -206,7 +208,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@@ -221,7 +223,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -237,7 +239,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -253,7 +255,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@@ -272,7 +274,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@@ -289,7 +291,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testParallelInvocations(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
first_callback = testing_callback.Callback()
@@ -316,7 +318,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -332,7 +334,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@@ -347,7 +349,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@@ -364,7 +366,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for unused_test_messages in test_messages_sequence:
callback = testing_callback.Callback()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
index 485524a356..cae791af97 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
@@ -34,6 +34,8 @@ import contextlib
import threading
import unittest
+import six
+
from grpc.framework.face import exceptions
from grpc.framework.foundation import future
from grpc.framework.foundation import logging_pool
@@ -66,6 +68,9 @@ class _PauseableIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._paused:
@@ -74,12 +79,12 @@ class _PauseableIterator(object):
class FutureInvocationAsynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
@@ -105,7 +110,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -117,7 +122,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -129,7 +134,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -145,7 +150,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -161,7 +166,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSequentialInvocations(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -180,7 +185,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -195,7 +200,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -207,7 +212,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -222,7 +227,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -234,7 +239,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -253,7 +258,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -268,7 +273,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -287,7 +292,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -302,7 +307,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testParallelInvocations(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -324,7 +329,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -338,7 +343,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -352,7 +357,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -366,7 +371,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
- self.digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
index 5932dabf1e..8a25f89c88 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
@@ -31,13 +31,14 @@
import abc
+import six
+
# cardinality is referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""An RPC method to be used in tests of RPC implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/service.py b/src/python/grpcio/tests/unit/framework/face/testing/service.py
index ac0b89b6ee..3e4228cc07 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/service.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/service.py
@@ -31,16 +31,16 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces
-class UnaryUnaryTestMethodImplementation(interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-unary RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-stream RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-unary RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-stream RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented RPC methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def name(self):
"""Identifies the RPC service name used during the test.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
index 23d4d919c2..f29d400844 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
@@ -31,18 +31,19 @@
import abc
+import six
+
# face_interfaces and interfaces are referenced in specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
-class FaceTestCase(object):
+class FaceTestCase(six.with_metaclass(abc.ABCMeta)):
"""Describes a test of the Face Layer of RPC Framework.
Concrete subclasses must also inherit from unittest.TestCase and from at least
one class that defines test methods.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_up_implementation(
diff --git a/src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py b/src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py
index 0521e1c102..330e445d43 100644
--- a/src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py
+++ b/src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
index 38102b198a..0eb38abf22 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
@@ -29,6 +29,8 @@
"""Part of the tests of the base interface of RPC Framework."""
+from __future__ import division
+
import abc
import collections
import enum
@@ -36,6 +38,8 @@ import random # pylint: disable=unused-import
import threading
import time
+import six
+
from grpc.framework.interfaces.base import base
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.base import _sequence
@@ -45,8 +49,8 @@ from tests.unit.framework.interfaces.base import test_interfaces # pylint: disa
_GROUP = 'base test cases test group'
_METHOD = 'base test cases test method'
-_PAYLOAD_RANDOM_SECTION_MAXIMUM_SIZE = test_constants.PAYLOAD_SIZE / 20
-_MINIMUM_PAYLOAD_SIZE = test_constants.PAYLOAD_SIZE / 600
+_PAYLOAD_RANDOM_SECTION_MAXIMUM_SIZE = test_constants.PAYLOAD_SIZE // 20
+_MINIMUM_PAYLOAD_SIZE = test_constants.PAYLOAD_SIZE // 600
def _create_payload(randomness):
@@ -57,7 +61,7 @@ def _create_payload(randomness):
random_section = bytes(
bytearray(
randomness.getrandbits(8) for _ in range(random_section_length)))
- sevens_section = '\x07' * (length - random_section_length)
+ sevens_section = b'\x07' * (length - random_section_length)
return b''.join(randomness.sample((random_section, sevens_section), 2))
@@ -247,8 +251,7 @@ class Instruction(
CONCLUDE = 'CONCLUDE'
-class Controller(object):
- __metaclass__ = abc.ABCMeta
+class Controller(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def failed(self, message):
@@ -308,8 +311,7 @@ class Controller(object):
raise NotImplementedError()
-class ControllerCreator(object):
- __metaclass__ = abc.ABCMeta
+class ControllerCreator(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def name(self):
@@ -385,13 +387,13 @@ class _SequenceController(Controller):
return request + request
def deserialize_request(self, serialized_request):
- return serialized_request[:len(serialized_request) / 2]
+ return serialized_request[:len(serialized_request) // 2]
def serialize_response(self, response):
return response * 3
def deserialize_response(self, serialized_response):
- return serialized_response[2 * len(serialized_response) / 3:]
+ return serialized_response[2 * len(serialized_response) // 3:]
def invocation(self):
with self._condition:
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
index 84afd24d47..5eba475ba8 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
@@ -31,12 +31,13 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base # pylint: disable=unused-import
-class Serialization(object):
+class Serialization(six.with_metaclass(abc.ABCMeta)):
"""Specifies serialization and deserialization of test payloads."""
- __metaclass__ = abc.ABCMeta
def serialize_request(self, request):
"""Serializes a request value used in a test.
@@ -85,9 +86,8 @@ class Serialization(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Base layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(self, serializations, servicer):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index c8a3a1bc74..649892463a 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -29,11 +29,15 @@
"""Test code for the Face layer of RPC Framework."""
+from __future__ import division
+
import abc
import itertools
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -46,14 +50,13 @@ from tests.unit.framework.interfaces.face import _stock_service
from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'BlockingInvocationInlineServiceTest'
@@ -81,7 +84,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -92,7 +95,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -104,7 +107,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -115,7 +118,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -127,7 +130,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSequentialInvocations(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -145,7 +148,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -167,7 +170,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -181,7 +184,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
some_completed_response_futures_iterator = itertools.islice(
futures.as_completed(response_futures_to_indices),
- test_constants.PARALLELISM / 2)
+ test_constants.PARALLELISM // 2)
for response_future in some_completed_response_futures_iterator:
index = response_futures_to_indices[response_future]
test_messages.verify(requests[index], response_future.result(), self)
@@ -205,7 +208,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -216,7 +219,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -228,7 +231,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -239,7 +242,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -251,7 +254,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -261,7 +264,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -272,7 +275,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -282,7 +285,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
index 9304b6b1db..f0befb0b27 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
@@ -32,6 +32,8 @@
import collections
import threading
+import six
+
# test_control, _service, and test_interfaces are referenced from specification
# in this module.
from grpc.framework.common import cardinality
@@ -363,7 +365,7 @@ def _assemble(
events = {}
adaptations = {}
messages = {}
- for identifier, scenario in scenarios.iteritems():
+ for identifier, scenario in six.iteritems(scenarios):
if identifier in identifiers:
raise ValueError('Repeated identifier "(%s, %s)"!' % identifier)
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index 1d36a931e8..c3813d5f3a 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,8 @@
"""Test code for the Face layer of RPC Framework."""
+from __future__ import division
+
import abc
import contextlib
import itertools
@@ -36,6 +38,8 @@ import threading
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -67,6 +71,9 @@ class _PauseableIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._paused:
@@ -104,14 +111,13 @@ class _Callback(object):
self._condition.wait()
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'FutureInvocationAsynchronousEventServiceTest'
@@ -141,7 +147,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -156,7 +162,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -168,7 +174,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -188,7 +194,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -204,7 +210,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSequentialInvocations(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -223,7 +229,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testParallelInvocations(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -239,7 +245,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
test_messages.verify(second_request, second_response, self)
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -259,7 +265,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -273,7 +279,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
some_completed_response_futures_iterator = itertools.islice(
futures.as_completed(response_futures_to_indices),
- test_constants.PARALLELISM / 2)
+ test_constants.PARALLELISM // 2)
for response_future in some_completed_response_futures_iterator:
index = response_futures_to_indices[response_future]
test_messages.verify(requests[index], response_future.result(), self)
@@ -281,7 +287,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -298,7 +304,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -312,7 +318,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -329,7 +335,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -343,7 +349,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -360,7 +366,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -372,7 +378,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -389,7 +395,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -401,7 +407,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -423,7 +429,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -438,7 +444,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -460,7 +466,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
index 448e845a08..ac487bed4f 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.common import cardinality
_CARDINALITY_TO_GENERIC_BLOCKING_BEHAVIOR = {
@@ -62,9 +64,8 @@ _CARDINALITY_TO_MULTI_CALLABLE_ATTRIBUTE = {
}
-class Invoker(object):
+class Invoker(six.with_metaclass(abc.ABCMeta)):
"""A type used to invoke test RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking(self, group, name):
@@ -82,9 +83,8 @@ class Invoker(object):
raise NotImplementedError()
-class InvokerConstructor(object):
+class InvokerConstructor(six.with_metaclass(abc.ABCMeta)):
"""A type used to create Invokers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
index 42a7f4e3b8..48f31fc677 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
index 28941e2ad0..f13dff0558 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
@@ -31,16 +31,16 @@
import abc
+import six
+
# face is referenced from specification in this module.
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
from tests.unit.framework.interfaces.face import test_interfaces
-class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(test_interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(test_interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(test_interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def unary_unary_scenarios(self):
"""Affords unary-request-unary-response test methods and their messages.
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
index 06b9d77e52..71de9d835e 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
index b2b5c10fa6..40f38e68ba 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
@@ -31,13 +31,14 @@
import abc
+import six
+
from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""Specifies a method to be used in tests."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group(self):
@@ -126,9 +127,8 @@ class Method(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Face layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
index dace6c23f3..608e64119e 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.interfaces.links import links
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.links import test_utilities
@@ -58,13 +60,12 @@ _TRANSMISSION_GROUP = 'test.Group'
_TRANSMISSION_METHOD = 'TestMethod'
-class TransmissionTest(object):
+class TransmissionTest(six.with_metaclass(abc.ABCMeta)):
"""Tests ticket transmission between two connected links.
This class must be mixed into a unittest.TestCase that implements the abstract
methods it provides.
"""
- __metaclass__ = abc.ABCMeta
# This is a unittest.TestCase mix-in.
# pylint: disable=invalid-name
diff --git a/src/python/grpcio/tests/unit/test_common.py b/src/python/grpcio/tests/unit/test_common.py
index 29431bfb9d..7b4d20dccb 100644
--- a/src/python/grpcio/tests/unit/test_common.py
+++ b/src/python/grpcio/tests/unit/test_common.py
@@ -31,6 +31,8 @@
import collections
+import six
+
INVOCATION_INITIAL_METADATA = ((b'0', b'abc'), (b'1', b'def'), (b'2', b'ghi'),)
SERVICE_INITIAL_METADATA = ((b'3', b'jkl'), (b'4', b'mno'), (b'5', b'pqr'),)
SERVICE_TERMINAL_METADATA = ((b'6', b'stu'), (b'7', b'vwx'), (b'8', b'yza'),)
@@ -65,7 +67,7 @@ def metadata_transmitted(original_metadata, transmitted_metadata):
key, value = tuple(key_value_pair)
transmitted[key].append(value)
- for key, values in original.iteritems():
+ for key, values in six.iteritems(original):
transmitted_values = transmitted[key]
transmitted_iterator = iter(transmitted_values)
try: