diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-01-22 01:27:00 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-01-22 01:27:00 +0000 |
commit | 2d6daa72ab5832bf4cab38df0d911f32df547021 (patch) | |
tree | 5f9304a6ff2c7c0cb7ed62eead92bf05411666f8 /python/google/protobuf/service_reflection.py | |
parent | 87e64e1ceeff224043078e7e31fe0b1a119c8b1a (diff) |
Push out changes from internal codebase.
All Languages
* Repeated fields of primitive types (types other that string, group, and
nested messages) may now use the option [packed = true] to get a more
efficient encoding. In the new encoding, the entire list is written
as a single byte blob using the "length-delimited" wire type. Within
this blob, the individual values are encoded the same way they would
be normally except without a tag before each value (thus, they are
tightly "packed").
C++
* UnknownFieldSet now supports STL-like iteration.
* Message interface has method ParseFromBoundedZeroCopyStream() which parses
a limited number of bytes from an input stream rather than parsing until
EOF.
Java
* Fixed bug where Message.mergeFrom(Message) failed to merge extensions.
* Message interface has new method toBuilder() which is equivalent to
newBuilderForType().mergeFrom(this).
* All enums now implement the ProtocolMessageEnum interface.
* Setting a field to null now throws NullPointerException.
* Fixed tendency for TextFormat's parsing to overflow the stack when
parsing large string values. The underlying problem is with Java's
regex implementation (which unfortunately uses recursive backtracking
rather than building an NFA). Worked around by making use of possesive
quantifiers.
Python
* Updated RPC interfaces to allow for blocking operation. A client may
now pass None for a callback when making an RPC, in which case the
call will block until the response is received, and the response
object will be returned directly to the caller. This interface change
cannot be used in practice until RPC implementations are updated to
implement it.
Diffstat (limited to 'python/google/protobuf/service_reflection.py')
-rwxr-xr-x | python/google/protobuf/service_reflection.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/python/google/protobuf/service_reflection.py b/python/google/protobuf/service_reflection.py index bdd6bad5..851e83e7 100755 --- a/python/google/protobuf/service_reflection.py +++ b/python/google/protobuf/service_reflection.py @@ -142,24 +142,17 @@ class _ServiceBuilder(object): # instance to the method that does the real CallMethod work. def _WrapCallMethod(srvc, method_descriptor, rpc_controller, request, callback): - self._CallMethod(srvc, method_descriptor, + return self._CallMethod(srvc, method_descriptor, rpc_controller, request, callback) self.cls = cls cls.CallMethod = _WrapCallMethod - cls.GetDescriptor = self._GetDescriptor + cls.GetDescriptor = staticmethod(lambda: self.descriptor) + cls.GetDescriptor.__doc__ = "Returns the service descriptor." cls.GetRequestClass = self._GetRequestClass cls.GetResponseClass = self._GetResponseClass for method in self.descriptor.methods: setattr(cls, method.name, self._GenerateNonImplementedMethod(method)) - def _GetDescriptor(self): - """Retrieves the service descriptor. - - Returns: - The descriptor of the service (of type ServiceDescriptor). - """ - return self.descriptor - def _CallMethod(self, srvc, method_descriptor, rpc_controller, request, callback): """Calls the method described by a given method descriptor. @@ -175,7 +168,7 @@ class _ServiceBuilder(object): raise RuntimeError( 'CallMethod() given method descriptor for wrong service type.') method = getattr(srvc, method_descriptor.name) - method(rpc_controller, request, callback) + return method(rpc_controller, request, callback) def _GetRequestClass(self, method_descriptor): """Returns the class of the request protocol message. @@ -270,8 +263,8 @@ class _ServiceStubBuilder(object): setattr(cls, method.name, self._GenerateStubMethod(method)) def _GenerateStubMethod(self, method): - return lambda inst, rpc_controller, request, callback: self._StubMethod( - inst, method, rpc_controller, request, callback) + return (lambda inst, rpc_controller, request, callback=None: + self._StubMethod(inst, method, rpc_controller, request, callback)) def _StubMethod(self, stub, method_descriptor, rpc_controller, request, callback): @@ -283,7 +276,9 @@ class _ServiceStubBuilder(object): rpc_controller: Rpc controller to execute the method. request: Request protocol message. callback: A callback to execute when the method finishes. + Returns: + Response message (in case of blocking call). """ - stub.rpc_channel.CallMethod( + return stub.rpc_channel.CallMethod( method_descriptor, rpc_controller, request, method_descriptor.output_type._concrete_class, callback) |