Skip to content

Commit

Permalink
allow older grpc versions to raise AttributeError
Browse files Browse the repository at this point in the history
  • Loading branch information
jbraswell committed Jan 21, 2022
1 parent 618748d commit e1d5e5c
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ def set_trailing_metadata(self, *args, **kwargs):
return self._servicer_context.set_trailing_metadata(*args, **kwargs)

def trailing_metadata(self):
# This method was added to grpc.ServicerContext in gRPC v1.38.0. We do
# this hasattr check to maintain support for earlier gRPC versions.
if hasattr(self._servicer_context, "trailing_metadata"):
return self._servicer_context.trailing_metadata()
raise NotImplementedError()
return self._servicer_context.trailing_metadata()

def abort(self, code, details):
self.code = code
Expand Down

0 comments on commit e1d5e5c

Please sign in to comment.