Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions endpoints/bookstore-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ gRPC libraries and tools are installed, run:
--include_imports \
--include_source_info \
--proto_path=. \
--python_out=generated_pb2 \
--grpc_python_out=generated_pb2 \
--python_out=. \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this put the files in the same directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this wasn't previously needed because the sample relied on an beta version of gRPC that combined the protobuf generated source and the grpc generated source.

With this update, the protoc command generates 2 files, one of which depends on the other, with a specific module path (hence the location of these file at the root).

--grpc_python_out=. \
--descriptor_set_out=api_descriptor.pb \
bookstore.proto

Expand Down
6 changes: 4 additions & 2 deletions endpoints/bookstore-grpc/bookstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import threading

import six


class ShelfInfo(object):
"""The contents of a single shelf."""
Expand All @@ -33,7 +35,7 @@ def __init__(self):

def list_shelf(self):
with self._lock:
return [s._shelf for (_, s) in self._shelves.iteritems()]
return [s._shelf for (_, s) in six.iteritems(self._shelves)]

def create_shelf(self, shelf):
with self._lock:
Expand All @@ -54,7 +56,7 @@ def delete_shelf(self, shelf_id):
def list_books(self, shelf_id):
with self._lock:
return [book for (
_, book) in self._shelves[shelf_id]._books.iteritems()]
_, book) in six.iteritems(self._shelves[shelf_id]._books)]

def create_book(self, shelf_id, book):
with self._lock:
Expand Down
5 changes: 2 additions & 3 deletions endpoints/bookstore-grpc/bookstore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
import argparse

from google.protobuf import empty_pb2

import grpc

from generated_pb2 import bookstore_pb2
import bookstore_pb2_grpc


def run(host, port, api_key, auth_token, timeout):
"""Makes a basic ListShelves call against a gRPC Bookstore server."""

channel = grpc.insecure_channel('{}:{}'.format(host, port))

stub = bookstore_pb2.BookstoreStub(channel)
stub = bookstore_pb2_grpc.BookstoreStub(channel)
metadata = []
if api_key:
metadata.append(('x-api-key', api_key))
Expand Down
Loading