pull/21458/head
Richard Belleville 5 years ago
parent 2c1efcd0ae
commit 24a66903a9
  1. 14
      examples/python/cancellation/search.py
  2. 4
      examples/python/cancellation/server.py
  3. 3
      examples/python/compression/server.py
  4. 4
      examples/python/debug/debug_server.py

@ -134,16 +134,14 @@ def search(target,
distance = _get_substring_hamming_distance(candidate_hash, target)
if interesting_hamming_distance is not None and distance <= interesting_hamming_distance:
# Surface interesting candidates, but don't stop.
yield protos.HashNameResponse(
secret=base64.b64encode(secret),
hashed_name=candidate_hash,
hamming_distance=distance)
yield protos.HashNameResponse(secret=base64.b64encode(secret),
hashed_name=candidate_hash,
hamming_distance=distance)
elif distance <= ideal_distance:
# Yield ideal candidate and end the stream.
yield protos.HashNameResponse(
secret=base64.b64encode(secret),
hashed_name=candidate_hash,
hamming_distance=distance)
yield protos.HashNameResponse(secret=base64.b64encode(secret),
hashed_name=candidate_hash,
hamming_distance=distance)
raise StopIteration() # pylint: disable=stop-iteration-return
hashes_computed += 1
if hashes_computed == maximum_hashes:

@ -90,8 +90,8 @@ def _running_server(port, maximum_hashes):
# threads.
server = grpc.server(futures.ThreadPoolExecutor(max_workers=1),
maximum_concurrent_rpcs=1)
services.add_HashFinderServicer_to_server(
HashFinder(maximum_hashes), server)
services.add_HashFinderServicer_to_server(HashFinder(maximum_hashes),
server)
address = '{}:{}'.format(_SERVER_HOST, port)
actual_port = server.add_insecure_port(address)
server.start()

@ -66,8 +66,7 @@ def run_server(server_compression, no_compress_every_n, port):
server = grpc.server(futures.ThreadPoolExecutor(),
compression=server_compression,
options=(('grpc.so_reuseport', 1),))
services.add_GreeterServicer_to_server(
Greeter(no_compress_every_n), server)
services.add_GreeterServicer_to_server(Greeter(no_compress_every_n), server)
address = '{}:{}'.format(_SERVER_HOST, port)
server.add_insecure_port(address)
server.start()

@ -51,8 +51,8 @@ class FaultInjectGreeter(services.GreeterServicer):
def create_server(addr, failure_rate):
server = grpc.server(futures.ThreadPoolExecutor())
services.add_GreeterServicer_to_server(
FaultInjectGreeter(failure_rate), server)
services.add_GreeterServicer_to_server(FaultInjectGreeter(failure_rate),
server)
# Add Channelz Servicer to the gRPC server
channelz.add_channelz_servicer(server)

Loading…
Cancel
Save