aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.github/CODEOWNERS1
-rw-r--r--examples/python/helloworld/greeter_client.py11
-rw-r--r--examples/python/helloworld/greeter_server.py26
-rw-r--r--examples/python/multiplex/multiplex_client.py130
-rw-r--r--examples/python/multiplex/multiplex_server.py181
-rw-r--r--examples/python/multiplex/route_guide_resources.py23
-rw-r--r--examples/python/multiplex/run_codegen.py23
-rw-r--r--examples/python/route_guide/route_guide_client.py113
-rw-r--r--examples/python/route_guide/route_guide_resources.py23
-rw-r--r--examples/python/route_guide/route_guide_server.py175
-rw-r--r--examples/python/route_guide/run_codegen.py12
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.cc2
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.cc8
-rw-r--r--src/core/lib/iomgr/executor.cc2
-rw-r--r--src/core/lib/iomgr/iomgr.cc2
-rw-r--r--src/core/lib/iomgr/timer_manager.cc4
-rw-r--r--src/core/lib/support/sync_posix.cc11
-rw-r--r--src/core/lib/surface/completion_queue.cc2
-rw-r--r--src/core/lib/surface/server.cc2
-rw-r--r--test/core/support/cpu_test.cc2
-rw-r--r--test/core/support/sync_test.cc12
-rw-r--r--test/cpp/util/cli_call.cc4
-rwxr-xr-xtools/distrib/yapf_code.sh2
-rw-r--r--tools/run_tests/performance/OWNERS9
24 files changed, 391 insertions, 389 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 094e43e470..cb322814fe 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -4,3 +4,4 @@
/**/OWNERS @markdroth @nicolasnoble @ctiller
/bazel/** @nicolasnoble @dgquintas @ctiller
/src/core/ext/filters/client_channel/** @markdroth @dgquintas @ctiller
+/tools/run_tests/performance/** @ncteisen @matt-kwong @ctiller
diff --git a/examples/python/helloworld/greeter_client.py b/examples/python/helloworld/greeter_client.py
index d9b2bdfd07..a0aeb47bd7 100644
--- a/examples/python/helloworld/greeter_client.py
+++ b/examples/python/helloworld/greeter_client.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
@@ -23,11 +22,11 @@ import helloworld_pb2_grpc
def run():
- channel = grpc.insecure_channel('localhost:50051')
- stub = helloworld_pb2_grpc.GreeterStub(channel)
- response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
- print("Greeter client received: " + response.message)
+ channel = grpc.insecure_channel('localhost:50051')
+ stub = helloworld_pb2_grpc.GreeterStub(channel)
+ response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
+ print("Greeter client received: " + response.message)
if __name__ == '__main__':
- run()
+ run()
diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py
index be61695616..c355662ef8 100644
--- a/examples/python/helloworld/greeter_server.py
+++ b/examples/python/helloworld/greeter_server.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the GRPC helloworld.Greeter server."""
from concurrent import futures
@@ -27,20 +26,21 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24
class Greeter(helloworld_pb2_grpc.GreeterServicer):
- def SayHello(self, request, context):
- return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
+ def SayHello(self, request, context):
+ return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
def serve():
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
- helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
- server.add_insecure_port('[::]:50051')
- server.start()
- try:
- while True:
- time.sleep(_ONE_DAY_IN_SECONDS)
- except KeyboardInterrupt:
- server.stop(0)
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
+
if __name__ == '__main__':
- serve()
+ serve()
diff --git a/examples/python/multiplex/multiplex_client.py b/examples/python/multiplex/multiplex_client.py
index c8c700afcd..49713f35b7 100644
--- a/examples/python/multiplex/multiplex_client.py
+++ b/examples/python/multiplex/multiplex_client.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""A client that makes both Greeter and RouteGuide RPCs."""
from __future__ import print_function
@@ -29,98 +28,99 @@ import route_guide_resources
def make_route_note(message, latitude, longitude):
- return route_guide_pb2.RouteNote(
- message=message,
- location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
+ return route_guide_pb2.RouteNote(
+ message=message,
+ location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
def guide_get_one_feature(route_guide_stub, point):
- feature = route_guide_stub.GetFeature(point)
- if not feature.location:
- print("Server returned incomplete feature")
- return
+ feature = route_guide_stub.GetFeature(point)
+ if not feature.location:
+ print("Server returned incomplete feature")
+ return
- if feature.name:
- print("Feature called %s at %s" % (feature.name, feature.location))
- else:
- print("Found no feature at %s" % feature.location)
+ if feature.name:
+ print("Feature called %s at %s" % (feature.name, feature.location))
+ else:
+ print("Found no feature at %s" % feature.location)
def guide_get_feature(route_guide_stub):
- guide_get_one_feature(
- route_guide_stub,
- route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
- guide_get_one_feature(
- route_guide_stub, route_guide_pb2.Point(latitude=0, longitude=0))
+ guide_get_one_feature(
+ route_guide_stub,
+ route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
+ guide_get_one_feature(route_guide_stub,
+ route_guide_pb2.Point(latitude=0, longitude=0))
def guide_list_features(route_guide_stub):
- rectangle = route_guide_pb2.Rectangle(
- lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
- hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
- print("Looking for features between 40, -75 and 42, -73")
+ rectangle = route_guide_pb2.Rectangle(
+ lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
+ hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
+ print("Looking for features between 40, -75 and 42, -73")
- features = route_guide_stub.ListFeatures(rectangle)
+ features = route_guide_stub.ListFeatures(rectangle)
- for feature in features:
- print("Feature called %s at %s" % (feature.name, feature.location))
+ for feature in features:
+ print("Feature called %s at %s" % (feature.name, feature.location))
def generate_route(feature_list):
- for _ in range(0, 10):
- random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
- print("Visiting point %s" % random_feature.location)
- yield random_feature.location
- time.sleep(random.uniform(0.5, 1.5))
+ for _ in range(0, 10):
+ random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
+ print("Visiting point %s" % random_feature.location)
+ yield random_feature.location
+ time.sleep(random.uniform(0.5, 1.5))
def guide_record_route(route_guide_stub):
- feature_list = route_guide_resources.read_route_guide_database()
+ feature_list = route_guide_resources.read_route_guide_database()
- route_iterator = generate_route(feature_list)
- route_summary = route_guide_stub.RecordRoute(route_iterator)
- print("Finished trip with %s points " % route_summary.point_count)
- print("Passed %s features " % route_summary.feature_count)
- print("Travelled %s meters " % route_summary.distance)
- print("It took %s seconds " % route_summary.elapsed_time)
+ route_iterator = generate_route(feature_list)
+ route_summary = route_guide_stub.RecordRoute(route_iterator)
+ print("Finished trip with %s points " % route_summary.point_count)
+ print("Passed %s features " % route_summary.feature_count)
+ print("Travelled %s meters " % route_summary.distance)
+ print("It took %s seconds " % route_summary.elapsed_time)
def generate_messages():
- messages = [
- make_route_note("First message", 0, 0),
- make_route_note("Second message", 0, 1),
- make_route_note("Third message", 1, 0),
- make_route_note("Fourth message", 0, 0),
- make_route_note("Fifth message", 1, 0),
- ]
- for msg in messages:
- print("Sending %s at %s" % (msg.message, msg.location))
- yield msg
- time.sleep(random.uniform(0.5, 1.0))
+ messages = [
+ make_route_note("First message", 0, 0),
+ make_route_note("Second message", 0, 1),
+ make_route_note("Third message", 1, 0),
+ make_route_note("Fourth message", 0, 0),
+ make_route_note("Fifth message", 1, 0),
+ ]
+ for msg in messages:
+ print("Sending %s at %s" % (msg.message, msg.location))
+ yield msg
+ time.sleep(random.uniform(0.5, 1.0))
def guide_route_chat(route_guide_stub):
- responses = route_guide_stub.RouteChat(generate_messages())
- for response in responses:
- print("Received message %s at %s" % (response.message, response.location))
+ responses = route_guide_stub.RouteChat(generate_messages())
+ for response in responses:
+ print("Received message %s at %s" %
+ (response.message, response.location))
def run():
- channel = grpc.insecure_channel('localhost:50051')
- greeter_stub = helloworld_pb2_grpc.GreeterStub(channel)
- route_guide_stub = route_guide_pb2_grpc.RouteGuideStub(channel)
- greeter_response = greeter_stub.SayHello(
- helloworld_pb2.HelloRequest(name='you'))
- print("Greeter client received: " + greeter_response.message)
- print("-------------- GetFeature --------------")
- guide_get_feature(route_guide_stub)
- print("-------------- ListFeatures --------------")
- guide_list_features(route_guide_stub)
- print("-------------- RecordRoute --------------")
- guide_record_route(route_guide_stub)
- print("-------------- RouteChat --------------")
- guide_route_chat(route_guide_stub)
+ channel = grpc.insecure_channel('localhost:50051')
+ greeter_stub = helloworld_pb2_grpc.GreeterStub(channel)
+ route_guide_stub = route_guide_pb2_grpc.RouteGuideStub(channel)
+ greeter_response = greeter_stub.SayHello(
+ helloworld_pb2.HelloRequest(name='you'))
+ print("Greeter client received: " + greeter_response.message)
+ print("-------------- GetFeature --------------")
+ guide_get_feature(route_guide_stub)
+ print("-------------- ListFeatures --------------")
+ guide_list_features(route_guide_stub)
+ print("-------------- RecordRoute --------------")
+ guide_record_route(route_guide_stub)
+ print("-------------- RouteChat --------------")
+ guide_route_chat(route_guide_stub)
if __name__ == '__main__':
- run()
+ run()
diff --git a/examples/python/multiplex/multiplex_server.py b/examples/python/multiplex/multiplex_server.py
index 9a6e835bed..e2ff671f97 100644
--- a/examples/python/multiplex/multiplex_server.py
+++ b/examples/python/multiplex/multiplex_server.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""A gRPC server servicing both Greeter and RouteGuide RPCs."""
from concurrent import futures
@@ -30,107 +29,111 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24
def _get_feature(feature_db, point):
- """Returns Feature at given location or None."""
- for feature in feature_db:
- if feature.location == point:
- return feature
- return None
+ """Returns Feature at given location or None."""
+ for feature in feature_db:
+ if feature.location == point:
+ return feature
+ return None
def _get_distance(start, end):
- """Distance between two points."""
- coord_factor = 10000000.0
- lat_1 = start.latitude / coord_factor
- lat_2 = end.latitude / coord_factor
- lon_1 = start.longitude / coord_factor
- lon_2 = end.longitude / coord_factor
- lat_rad_1 = math.radians(lat_1)
- lat_rad_2 = math.radians(lat_2)
- delta_lat_rad = math.radians(lat_2 - lat_1)
- delta_lon_rad = math.radians(lon_2 - lon_1)
-
- a = (pow(math.sin(delta_lat_rad / 2), 2) +
- (math.cos(lat_rad_1) * math.cos(lat_rad_2) *
- pow(math.sin(delta_lon_rad / 2), 2)))
- c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
- R = 6371000; # metres
- return R * c;
+ """Distance between two points."""
+ coord_factor = 10000000.0
+ lat_1 = start.latitude / coord_factor
+ lat_2 = end.latitude / coord_factor
+ lon_1 = start.longitude / coord_factor
+ lon_2 = end.longitude / coord_factor
+ lat_rad_1 = math.radians(lat_1)
+ lat_rad_2 = math.radians(lat_2)
+ delta_lat_rad = math.radians(lat_2 - lat_1)
+ delta_lon_rad = math.radians(lon_2 - lon_1)
+
+ a = (pow(math.sin(delta_lat_rad / 2), 2) +
+ (math.cos(lat_rad_1) * math.cos(lat_rad_2) * pow(
+ math.sin(delta_lon_rad / 2), 2)))
+ c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
+ R = 6371000
+ # metres
+ return R * c
class _GreeterServicer(helloworld_pb2_grpc.GreeterServicer):
- def SayHello(self, request, context):
- return helloworld_pb2.HelloReply(message='Hello, {}!'.format(request.name))
+ def SayHello(self, request, context):
+ return helloworld_pb2.HelloReply(
+ message='Hello, {}!'.format(request.name))
class _RouteGuideServicer(route_guide_pb2_grpc.RouteGuideServicer):
- """Provides methods that implement functionality of route guide server."""
-
- def __init__(self):
- self.db = route_guide_resources.read_route_guide_database()
-
- def GetFeature(self, request, context):
- feature = _get_feature(self.db, request)
- if feature is None:
- return route_guide_pb2.Feature(name="", location=request)
- else:
- return feature
-
- def ListFeatures(self, request, context):
- left = min(request.lo.longitude, request.hi.longitude)
- right = max(request.lo.longitude, request.hi.longitude)
- top = max(request.lo.latitude, request.hi.latitude)
- bottom = min(request.lo.latitude, request.hi.latitude)
- for feature in self.db:
- if (feature.location.longitude >= left and
- feature.location.longitude <= right and
- feature.location.latitude >= bottom and
- feature.location.latitude <= top):
- yield feature
-
- def RecordRoute(self, request_iterator, context):
- point_count = 0
- feature_count = 0
- distance = 0.0
- prev_point = None
-
- start_time = time.time()
- for point in request_iterator:
- point_count += 1
- if _get_feature(self.db, point):
- feature_count += 1
- if prev_point:
- distance += _get_distance(prev_point, point)
- prev_point = point
-
- elapsed_time = time.time() - start_time
- return route_guide_pb2.RouteSummary(point_count=point_count,
- feature_count=feature_count,
- distance=int(distance),
- elapsed_time=int(elapsed_time))
-
- def RouteChat(self, request_iterator, context):
- prev_notes = []
- for new_note in request_iterator:
- for prev_note in prev_notes:
- if prev_note.location == new_note.location:
- yield prev_note
- prev_notes.append(new_note)
+ """Provides methods that implement functionality of route guide server."""
+
+ def __init__(self):
+ self.db = route_guide_resources.read_route_guide_database()
+
+ def GetFeature(self, request, context):
+ feature = _get_feature(self.db, request)
+ if feature is None:
+ return route_guide_pb2.Feature(name="", location=request)
+ else:
+ return feature
+
+ def ListFeatures(self, request, context):
+ left = min(request.lo.longitude, request.hi.longitude)
+ right = max(request.lo.longitude, request.hi.longitude)
+ top = max(request.lo.latitude, request.hi.latitude)
+ bottom = min(request.lo.latitude, request.hi.latitude)
+ for feature in self.db:
+ if (feature.location.longitude >= left and
+ feature.location.longitude <= right and
+ feature.location.latitude >= bottom and
+ feature.location.latitude <= top):
+ yield feature
+
+ def RecordRoute(self, request_iterator, context):
+ point_count = 0
+ feature_count = 0
+ distance = 0.0
+ prev_point = None
+
+ start_time = time.time()
+ for point in request_iterator:
+ point_count += 1
+ if _get_feature(self.db, point):
+ feature_count += 1
+ if prev_point:
+ distance += _get_distance(prev_point, point)
+ prev_point = point
+
+ elapsed_time = time.time() - start_time
+ return route_guide_pb2.RouteSummary(
+ point_count=point_count,
+ feature_count=feature_count,
+ distance=int(distance),
+ elapsed_time=int(elapsed_time))
+
+ def RouteChat(self, request_iterator, context):
+ prev_notes = []
+ for new_note in request_iterator:
+ for prev_note in prev_notes:
+ if prev_note.location == new_note.location:
+ yield prev_note
+ prev_notes.append(new_note)
def serve():
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
- helloworld_pb2_grpc.add_GreeterServicer_to_server(_GreeterServicer(), server)
- route_guide_pb2_grpc.add_RouteGuideServicer_to_server(
- _RouteGuideServicer(), server)
- server.add_insecure_port('[::]:50051')
- server.start()
- try:
- while True:
- time.sleep(_ONE_DAY_IN_SECONDS)
- except KeyboardInterrupt:
- server.stop(0)
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ helloworld_pb2_grpc.add_GreeterServicer_to_server(_GreeterServicer(),
+ server)
+ route_guide_pb2_grpc.add_RouteGuideServicer_to_server(_RouteGuideServicer(),
+ server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
if __name__ == '__main__':
- serve()
+ serve()
diff --git a/examples/python/multiplex/route_guide_resources.py b/examples/python/multiplex/route_guide_resources.py
index 0887863660..ace85d6f9d 100644
--- a/examples/python/multiplex/route_guide_resources.py
+++ b/examples/python/multiplex/route_guide_resources.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""Common resources used in the gRPC route guide example."""
import json
@@ -20,19 +19,19 @@ import route_guide_pb2
def read_route_guide_database():
- """Reads the route guide database.
+ """Reads the route guide database.
Returns:
The full contents of the route guide database as a sequence of
route_guide_pb2.Features.
"""
- feature_list = []
- with open("route_guide_db.json") as route_guide_db_file:
- for item in json.load(route_guide_db_file):
- feature = route_guide_pb2.Feature(
- name=item["name"],
- location=route_guide_pb2.Point(
- latitude=item["location"]["latitude"],
- longitude=item["location"]["longitude"]))
- feature_list.append(feature)
- return feature_list
+ feature_list = []
+ with open("route_guide_db.json") as route_guide_db_file:
+ for item in json.load(route_guide_db_file):
+ feature = route_guide_pb2.Feature(
+ name=item["name"],
+ location=route_guide_pb2.Point(
+ latitude=item["location"]["latitude"],
+ longitude=item["location"]["longitude"]))
+ feature_list.append(feature)
+ return feature_list
diff --git a/examples/python/multiplex/run_codegen.py b/examples/python/multiplex/run_codegen.py
index f38d86cf43..d960c3cf16 100644
--- a/examples/python/multiplex/run_codegen.py
+++ b/examples/python/multiplex/run_codegen.py
@@ -11,26 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""Generates protocol messages and gRPC stubs."""
from grpc_tools import protoc
-protoc.main(
- (
- '',
- '-I../../protos',
- '--python_out=.',
- '--grpc_python_out=.',
- '../../protos/helloworld.proto',
- )
-)
-protoc.main(
- (
- '',
- '-I../../protos',
- '--python_out=.',
- '--grpc_python_out=.',
- '../../protos/route_guide.proto',
- )
-)
+protoc.main(('', '-I../../protos', '--python_out=.', '--grpc_python_out=.',
+ '../../protos/helloworld.proto',))
+protoc.main(('', '-I../../protos', '--python_out=.', '--grpc_python_out=.',
+ '../../protos/route_guide.proto',))
diff --git a/examples/python/route_guide/route_guide_client.py b/examples/python/route_guide/route_guide_client.py
index a0e32fb6f5..c9d0e96ad6 100644
--- a/examples/python/route_guide/route_guide_client.py
+++ b/examples/python/route_guide/route_guide_client.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the gRPC route guide client."""
from __future__ import print_function
@@ -26,89 +25,91 @@ import route_guide_resources
def make_route_note(message, latitude, longitude):
- return route_guide_pb2.RouteNote(
- message=message,
- location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
+ return route_guide_pb2.RouteNote(
+ message=message,
+ location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
def guide_get_one_feature(stub, point):
- feature = stub.GetFeature(point)
- if not feature.location:
- print("Server returned incomplete feature")
- return
+ feature = stub.GetFeature(point)
+ if not feature.location:
+ print("Server returned incomplete feature")
+ return
- if feature.name:
- print("Feature called %s at %s" % (feature.name, feature.location))
- else:
- print("Found no feature at %s" % feature.location)
+ if feature.name:
+ print("Feature called %s at %s" % (feature.name, feature.location))
+ else:
+ print("Found no feature at %s" % feature.location)
def guide_get_feature(stub):
- guide_get_one_feature(stub, route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
- guide_get_one_feature(stub, route_guide_pb2.Point(latitude=0, longitude=0))
+ guide_get_one_feature(
+ stub, route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
+ guide_get_one_feature(stub, route_guide_pb2.Point(latitude=0, longitude=0))
def guide_list_features(stub):
- rectangle = route_guide_pb2.Rectangle(
- lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
- hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
- print("Looking for features between 40, -75 and 42, -73")
+ rectangle = route_guide_pb2.Rectangle(
+ lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
+ hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
+ print("Looking for features between 40, -75 and 42, -73")
- features = stub.ListFeatures(rectangle)
+ features = stub.ListFeatures(rectangle)
- for feature in features:
- print("Feature called %s at %s" % (feature.name, feature.location))
+ for feature in features:
+ print("Feature called %s at %s" % (feature.name, feature.location))
def generate_route(feature_list):
- for _ in range(0, 10):
- random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
- print("Visiting point %s" % random_feature.location)
- yield random_feature.location
+ for _ in range(0, 10):
+ random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
+ print("Visiting point %s" % random_feature.location)
+ yield random_feature.location
def guide_record_route(stub):
- feature_list = route_guide_resources.read_route_guide_database()
+ feature_list = route_guide_resources.read_route_guide_database()
- route_iterator = generate_route(feature_list)
- route_summary = stub.RecordRoute(route_iterator)
- print("Finished trip with %s points " % route_summary.point_count)
- print("Passed %s features " % route_summary.feature_count)
- print("Travelled %s meters " % route_summary.distance)
- print("It took %s seconds " % route_summary.elapsed_time)
+ route_iterator = generate_route(feature_list)
+ route_summary = stub.RecordRoute(route_iterator)
+ print("Finished trip with %s points " % route_summary.point_count)
+ print("Passed %s features " % route_summary.feature_count)
+ print("Travelled %s meters " % route_summary.distance)
+ print("It took %s seconds " % route_summary.elapsed_time)
def generate_messages():
- messages = [
- make_route_note("First message", 0, 0),
- make_route_note("Second message", 0, 1),
- make_route_note("Third message", 1, 0),
- make_route_note("Fourth message", 0, 0),
- make_route_note("Fifth message", 1, 0),
- ]
- for msg in messages:
- print("Sending %s at %s" % (msg.message, msg.location))
- yield msg
+ messages = [
+ make_route_note("First message", 0, 0),
+ make_route_note("Second message", 0, 1),
+ make_route_note("Third message", 1, 0),
+ make_route_note("Fourth message", 0, 0),
+ make_route_note("Fifth message", 1, 0),
+ ]
+ for msg in messages:
+ print("Sending %s at %s" % (msg.message, msg.location))
+ yield msg
def guide_route_chat(stub):
- responses = stub.RouteChat(generate_messages())
- for response in responses:
- print("Received message %s at %s" % (response.message, response.location))
+ responses = stub.RouteChat(generate_messages())
+ for response in responses:
+ print("Received message %s at %s" %
+ (response.message, response.location))
def run():
- channel = grpc.insecure_channel('localhost:50051')
- stub = route_guide_pb2_grpc.RouteGuideStub(channel)
- print("-------------- GetFeature --------------")
- guide_get_feature(stub)
- print("-------------- ListFeatures --------------")
- guide_list_features(stub)
- print("-------------- RecordRoute --------------")
- guide_record_route(stub)
- print("-------------- RouteChat --------------")
- guide_route_chat(stub)
+ channel = grpc.insecure_channel('localhost:50051')
+ stub = route_guide_pb2_grpc.RouteGuideStub(channel)
+ print("-------------- GetFeature --------------")
+ guide_get_feature(stub)
+ print("-------------- ListFeatures --------------")
+ guide_list_features(stub)
+ print("-------------- RecordRoute --------------")
+ guide_record_route(stub)
+ print("-------------- RouteChat --------------")
+ guide_route_chat(stub)
if __name__ == '__main__':
- run()
+ run()
diff --git a/examples/python/route_guide/route_guide_resources.py b/examples/python/route_guide/route_guide_resources.py
index 0887863660..ace85d6f9d 100644
--- a/examples/python/route_guide/route_guide_resources.py
+++ b/examples/python/route_guide/route_guide_resources.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""Common resources used in the gRPC route guide example."""
import json
@@ -20,19 +19,19 @@ import route_guide_pb2
def read_route_guide_database():
- """Reads the route guide database.
+ """Reads the route guide database.
Returns:
The full contents of the route guide database as a sequence of
route_guide_pb2.Features.
"""
- feature_list = []
- with open("route_guide_db.json") as route_guide_db_file:
- for item in json.load(route_guide_db_file):
- feature = route_guide_pb2.Feature(
- name=item["name"],
- location=route_guide_pb2.Point(
- latitude=item["location"]["latitude"],
- longitude=item["location"]["longitude"]))
- feature_list.append(feature)
- return feature_list
+ feature_list = []
+ with open("route_guide_db.json") as route_guide_db_file:
+ for item in json.load(route_guide_db_file):
+ feature = route_guide_pb2.Feature(
+ name=item["name"],
+ location=route_guide_pb2.Point(
+ latitude=item["location"]["latitude"],
+ longitude=item["location"]["longitude"]))
+ feature_list.append(feature)
+ return feature_list
diff --git a/examples/python/route_guide/route_guide_server.py b/examples/python/route_guide/route_guide_server.py
index a0aa5fdb83..46f3322a39 100644
--- a/examples/python/route_guide/route_guide_server.py
+++ b/examples/python/route_guide/route_guide_server.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""The Python implementation of the gRPC route guide server."""
from concurrent import futures
@@ -28,98 +27,102 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24
def get_feature(feature_db, point):
- """Returns Feature at given location or None."""
- for feature in feature_db:
- if feature.location == point:
- return feature
- return None
+ """Returns Feature at given location or None."""
+ for feature in feature_db:
+ if feature.location == point:
+ return feature
+ return None
def get_distance(start, end):
- """Distance between two points."""
- coord_factor = 10000000.0
- lat_1 = start.latitude / coord_factor
- lat_2 = end.latitude / coord_factor
- lon_1 = start.longitude / coord_factor
- lon_2 = end.longitude / coord_factor
- lat_rad_1 = math.radians(lat_1)
- lat_rad_2 = math.radians(lat_2)
- delta_lat_rad = math.radians(lat_2 - lat_1)
- delta_lon_rad = math.radians(lon_2 - lon_1)
-
- a = (pow(math.sin(delta_lat_rad / 2), 2) +
- (math.cos(lat_rad_1) * math.cos(lat_rad_2) *
- pow(math.sin(delta_lon_rad / 2), 2)))
- c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
- R = 6371000; # metres
- return R * c;
+ """Distance between two points."""
+ coord_factor = 10000000.0
+ lat_1 = start.latitude / coord_factor
+ lat_2 = end.latitude / coord_factor
+ lon_1 = start.longitude / coord_factor
+ lon_2 = end.longitude / coord_factor
+ lat_rad_1 = math.radians(lat_1)
+ lat_rad_2 = math.radians(lat_2)
+ delta_lat_rad = math.radians(lat_2 - lat_1)
+ delta_lon_rad = math.radians(lon_2 - lon_1)
+
+ a = (pow(math.sin(delta_lat_rad / 2), 2) +
+ (math.cos(lat_rad_1) * math.cos(lat_rad_2) * pow(
+ math.sin(delta_lon_rad / 2), 2)))
+ c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
+ R = 6371000
+ # metres
+ return R * c
+
class RouteGuideServicer(route_guide_pb2_grpc.RouteGuideServicer):
- """Provides methods that implement functionality of route guide server."""
-
- def __init__(self):
- self.db = route_guide_resources.read_route_guide_database()
-
- def GetFeature(self, request, context):
- feature = get_feature(self.db, request)
- if feature is None:
- return route_guide_pb2.Feature(name="", location=request)
- else:
- return feature
-
- def ListFeatures(self, request, context):
- left = min(request.lo.longitude, request.hi.longitude)
- right = max(request.lo.longitude, request.hi.longitude)
- top = max(request.lo.latitude, request.hi.latitude)
- bottom = min(request.lo.latitude, request.hi.latitude)
- for feature in self.db:
- if (feature.location.longitude >= left and
- feature.location.longitude <= right and
- feature.location.latitude >= bottom and
- feature.location.latitude <= top):
- yield feature
-
- def RecordRoute(self, request_iterator, context):
- point_count = 0
- feature_count = 0
- distance = 0.0
- prev_point = None
-
- start_time = time.time()
- for point in request_iterator:
- point_count += 1
- if get_feature(self.db, point):
- feature_count += 1
- if prev_point:
- distance += get_distance(prev_point, point)
- prev_point = point
-
- elapsed_time = time.time() - start_time
- return route_guide_pb2.RouteSummary(point_count=point_count,
- feature_count=feature_count,
- distance=int(distance),
- elapsed_time=int(elapsed_time))
-
- def RouteChat(self, request_iterator, context):
- prev_notes = []
- for new_note in request_iterator:
- for prev_note in prev_notes:
- if prev_note.location == new_note.location:
- yield prev_note
- prev_notes.append(new_note)
+ """Provides methods that implement functionality of route guide server."""
+
+ def __init__(self):
+ self.db = route_guide_resources.read_route_guide_database()
+
+ def GetFeature(self, request, context):
+ feature = get_feature(self.db, request)
+ if feature is None:
+ return route_guide_pb2.Feature(name="", location=request)
+ else:
+ return feature
+
+ def ListFeatures(self, request, context):
+ left = min(request.lo.longitude, request.hi.longitude)
+ right = max(request.lo.longitude, request.hi.longitude)
+ top = max(request.lo.latitude, request.hi.latitude)
+ bottom = min(request.lo.latitude, request.hi.latitude)
+ for feature in self.db:
+ if (feature.location.longitude >= left and
+ feature.location.longitude <= right and
+ feature.location.latitude >= bottom and
+ feature.location.latitude <= top):
+ yield feature
+
+ def RecordRoute(self, request_iterator, context):
+ point_count = 0
+ feature_count = 0
+ distance = 0.0
+ prev_point = None
+
+ start_time = time.time()
+ for point in request_iterator:
+ point_count += 1
+ if get_feature(self.db, point):
+ feature_count += 1
+ if prev_point:
+ distance += get_distance(prev_point, point)
+ prev_point = point
+
+ elapsed_time = time.time() - start_time
+ return route_guide_pb2.RouteSummary(
+ point_count=point_count,
+ feature_count=feature_count,
+ distance=int(distance),
+ elapsed_time=int(elapsed_time))
+
+ def RouteChat(self, request_iterator, context):
+ prev_notes = []
+ for new_note in request_iterator:
+ for prev_note in prev_notes:
+ if prev_note.location == new_note.location:
+ yield prev_note
+ prev_notes.append(new_note)
def serve():
- server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
- route_guide_pb2_grpc.add_RouteGuideServicer_to_server(
- RouteGuideServicer(), server)
- server.add_insecure_port('[::]:50051')
- server.start()
- try:
- while True:
- time.sleep(_ONE_DAY_IN_SECONDS)
- except KeyboardInterrupt:
- server.stop(0)
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ route_guide_pb2_grpc.add_RouteGuideServicer_to_server(RouteGuideServicer(),
+ server)
+ server.add_insecure_port('[::]:50051')
+ server.start()
+ try:
+ while True:
+ time.sleep(_ONE_DAY_IN_SECONDS)
+ except KeyboardInterrupt:
+ server.stop(0)
+
if __name__ == '__main__':
- serve()
+ serve()
diff --git a/examples/python/route_guide/run_codegen.py b/examples/python/route_guide/run_codegen.py
index 4b61cf4faa..1ec7fcd51f 100644
--- a/examples/python/route_guide/run_codegen.py
+++ b/examples/python/route_guide/run_codegen.py
@@ -11,17 +11,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs."""
from grpc_tools import protoc
-protoc.main(
- (
- '',
- '-I../../protos',
- '--python_out=.',
- '--grpc_python_out=.',
- '../../protos/route_guide.proto',
- )
-)
+protoc.main(('', '-I../../protos', '--python_out=.', '--grpc_python_out=.',
+ '../../protos/route_guide.proto',))
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc
index d9e8a30f5e..ae9d47ece5 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.cc
+++ b/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -738,7 +738,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
}
if (gpr_cv_wait(&worker->cv, &pollset->mu,
- grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME)) &&
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC)) &&
worker->state == UNKICKED) {
/* If gpr_cv_wait returns true (i.e a timeout), pretend that the worker
received a kick */
diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc
index 006e3ddd2f..53de94fb6e 100644
--- a/src/core/lib/iomgr/ev_poll_posix.cc
+++ b/src/core/lib/iomgr/ev_poll_posix.cc
@@ -1471,7 +1471,7 @@ static void run_poll(void* args) {
decref_poll_result(result);
// Leave this polling thread alive for a grace period to do another poll()
// op
- gpr_timespec deadline = gpr_now(GPR_CLOCK_REALTIME);
+ gpr_timespec deadline = gpr_now(GPR_CLOCK_MONOTONIC);
deadline = gpr_time_add(deadline, thread_grace);
pargs->trigger_set = 0;
gpr_cv_wait(&pargs->trigger, &g_cvfds.mu, deadline);
@@ -1526,9 +1526,9 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
}
}
- gpr_timespec deadline = gpr_now(GPR_CLOCK_REALTIME);
+ gpr_timespec deadline = gpr_now(GPR_CLOCK_MONOTONIC);
if (timeout < 0) {
- deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
+ deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
} else {
deadline =
gpr_time_add(deadline, gpr_time_from_millis(timeout, GPR_TIMESPAN));
@@ -1631,7 +1631,7 @@ static void global_cv_fd_table_shutdown() {
// Not doing so will result in reported memory leaks
if (!gpr_unref(&g_cvfds.pollcount)) {
int res = gpr_cv_wait(&g_cvfds.shutdown_cv, &g_cvfds.mu,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(3, GPR_TIMESPAN)));
GPR_ASSERT(res == 0);
}
diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc
index b45223ce16..b7288d5bf3 100644
--- a/src/core/lib/iomgr/executor.cc
+++ b/src/core/lib/iomgr/executor.cc
@@ -155,7 +155,7 @@ static void executor_thread(void* arg) {
ts->depth -= subtract_depth;
while (grpc_closure_list_empty(ts->elems) && !ts->shutdown) {
ts->queued_long_job = false;
- gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
if (ts->shutdown) {
if (executor_trace.enabled()) {
diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc
index dacf08ea9e..70807c479d 100644
--- a/src/core/lib/iomgr/iomgr.cc
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -118,7 +118,7 @@ void grpc_iomgr_shutdown() {
abort();
}
gpr_timespec short_deadline =
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_millis(100, GPR_TIMESPAN));
if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) {
if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) >
diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc
index 8ca6a3c23e..7fb068f10f 100644
--- a/src/core/lib/iomgr/timer_manager.cc
+++ b/src/core/lib/iomgr/timer_manager.cc
@@ -192,7 +192,7 @@ static bool wait_until(grpc_millis next) {
}
gpr_cv_wait(&g_cv_wait, &g_mu,
- grpc_millis_to_timespec(next, GPR_CLOCK_REALTIME));
+ grpc_millis_to_timespec(next, GPR_CLOCK_MONOTONIC));
if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d",
@@ -317,7 +317,7 @@ static void stop_threads(void) {
gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count);
}
while (g_thread_count > 0) {
- gpr_cv_wait(&g_cv_shutdown, &g_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&g_cv_shutdown, &g_mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count);
}
diff --git a/src/core/lib/support/sync_posix.cc b/src/core/lib/support/sync_posix.cc
index dfdd233bf4..c3f6b10463 100644
--- a/src/core/lib/support/sync_posix.cc
+++ b/src/core/lib/support/sync_posix.cc
@@ -66,7 +66,12 @@ int gpr_mu_trylock(gpr_mu* mu) {
/*----------------------------------------*/
void gpr_cv_init(gpr_cv* cv) {
- GPR_ASSERT(pthread_cond_init(cv, nullptr) == 0);
+ pthread_condattr_t attr;
+ GPR_ASSERT(pthread_condattr_init(&attr) == 0);
+#if GPR_LINUX
+ GPR_ASSERT(pthread_condattr_setclock(&attr, CLOCK_MONOTONIC) == 0);
+#endif // GPR_LINUX
+ GPR_ASSERT(pthread_cond_init(cv, &attr) == 0);
}
void gpr_cv_destroy(gpr_cv* cv) { GPR_ASSERT(pthread_cond_destroy(cv) == 0); }
@@ -78,7 +83,11 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
err = pthread_cond_wait(cv, mu);
} else {
struct timespec abs_deadline_ts;
+#if GPR_LINUX
+ abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_MONOTONIC);
+#else
abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
+#endif // GPR_LINUX
abs_deadline_ts.tv_sec = (time_t)abs_deadline.tv_sec;
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc
index 12385b7130..aa5808da4c 100644
--- a/src/core/lib/surface/completion_queue.cc
+++ b/src/core/lib/surface/completion_queue.cc
@@ -115,7 +115,7 @@ static grpc_error* non_polling_poller_work(grpc_pollset* pollset,
}
w.kicked = false;
gpr_timespec deadline_ts =
- grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME);
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC);
while (!npp->shutdown && !w.kicked &&
!gpr_cv_wait(&w.cv, &npp->mu, deadline_ts))
;
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index 4f07183180..f1d428f0a1 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -1170,7 +1170,7 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
gpr_mu_lock(&server->mu_global);
while (server->starting) {
gpr_cv_wait(&server->starting_cv, &server->mu_global,
- gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
/* stay locked, and gather up some stuff to do */
diff --git a/test/core/support/cpu_test.cc b/test/core/support/cpu_test.cc
index 6e04feedaa..334c4318e1 100644
--- a/test/core/support/cpu_test.cc
+++ b/test/core/support/cpu_test.cc
@@ -115,7 +115,7 @@ static void cpu_test(void) {
}
gpr_mu_lock(&ct.mu);
while (!ct.is_done) {
- gpr_cv_wait(&ct.done_cv, &ct.mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&ct.done_cv, &ct.mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&ct.mu);
fprintf(stderr, "Saw cores [");
diff --git a/test/core/support/sync_test.cc b/test/core/support/sync_test.cc
index 3f534de820..fb7ec44754 100644
--- a/test/core/support/sync_test.cc
+++ b/test/core/support/sync_test.cc
@@ -73,7 +73,7 @@ void queue_append(queue* q, int x) {
corresponding condition variable. The predicate must be on state
protected by the lock. */
while (q->length == N) {
- gpr_cv_wait(&q->non_full, &q->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&q->non_full, &q->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
if (q->length == 0) { /* Wake threads blocked in queue_remove(). */
/* It's normal to use gpr_cv_broadcast() or gpr_signal() while
@@ -197,7 +197,7 @@ static void test_create_threads(struct test* m, void (*body)(void* arg)) {
static void test_wait(struct test* m) {
gpr_mu_lock(&m->mu);
while (m->done != 0) {
- gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&m->mu);
}
@@ -297,7 +297,7 @@ static void inc_by_turns(void* v /*=m*/) {
for (i = 0; i != m->iterations; i++) {
gpr_mu_lock(&m->mu);
while ((m->counter % m->threads) != id) {
- gpr_cv_wait(&m->cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&m->cv, &m->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
m->counter++;
gpr_cv_broadcast(&m->cv);
@@ -314,7 +314,7 @@ static void inc_with_1ms_delay(void* v /*=m*/) {
for (i = 0; i != m->iterations; i++) {
gpr_timespec deadline;
gpr_mu_lock(&m->mu);
- deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(1000, GPR_TIMESPAN));
while (!gpr_cv_wait(&m->cv, &m->mu, deadline)) {
}
@@ -370,14 +370,14 @@ static void consumer(void* v /*=m*/) {
int64_t i;
int value;
for (i = 0; i != n; i++) {
- queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_REALTIME));
+ queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_lock(&m->mu);
m->counter = n;
gpr_mu_unlock(&m->mu);
GPR_ASSERT(
!queue_remove(&m->q, &value,
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(1000000, GPR_TIMESPAN))));
mark_thread_done(m);
}
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index c3220efa54..4f1a20c727 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -126,7 +126,7 @@ void CliCall::WriteAndWait(const grpc::string& request) {
call_->Write(send_buffer, tag(2));
write_done_ = false;
while (!write_done_) {
- gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&write_mu_);
}
@@ -136,7 +136,7 @@ void CliCall::WritesDoneAndWait() {
call_->WritesDone(tag(4));
write_done_ = false;
while (!write_done_) {
- gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_cv_wait(&write_cv_, &write_mu_, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&write_mu_);
}
diff --git a/tools/distrib/yapf_code.sh b/tools/distrib/yapf_code.sh
index f096868660..44eb967c4b 100755
--- a/tools/distrib/yapf_code.sh
+++ b/tools/distrib/yapf_code.sh
@@ -19,11 +19,13 @@ set -ex
cd "$(dirname "${0}")/../.."
DIRS=(
+ 'examples/python'
'src/python'
'tools'
)
EXCLUSIONS=(
'*protoc_lib_deps.py' # this file is auto-generated
+ '*_pb2*.py' # no need to format protoc generated files
)
VIRTUALENV=yapf_virtual_environment
diff --git a/tools/run_tests/performance/OWNERS b/tools/run_tests/performance/OWNERS
new file mode 100644
index 0000000000..98c81529f3
--- /dev/null
+++ b/tools/run_tests/performance/OWNERS
@@ -0,0 +1,9 @@
+set noparent
+
+# These owners are in place to ensure that scenario_result_schema.json is not
+# modified without also running tools/run_tests/performance/patch_scenario_results_schema.py
+# to update the BigQuery schema
+
+@ncteisen
+@matt-kwong
+@ctiller