@contextmanager
def context(grpc_context):
 try:
  (yield)
 except KeyError as key_error:
  grpc_context.code(status.Code.NOT_FOUND)
  grpc_context.details('Unable to find the item keyed by {}'.format(key_error))

@ contextmanager def context ( grpc_context ) : try : ( yield ) except KeyError as key_error : grpc_context . code ( status . Code . NOT_FOUND ) grpc_context . details ( 'Unable to find the item keyed by {}' . format ( key_error ) )
work context - restful controller .