-Remove service.py usages in builder

-Raise warnings for deprecated google/protobuf/service.py APIs.

service.py APIs are marked as deprecated since 2010. These APIs will be
removed in Jan 2025

PiperOrigin-RevId: 653280370
pull/17505/head
Jie Luo 8 months ago committed by Copybara-Service
parent 65d4e1817a
commit 2967c521a6
  1. 3
      python/google/protobuf/internal/builder.py
  2. 8
      python/google/protobuf/service.py

@ -105,12 +105,11 @@ def BuildServices(file_des, module_name, module):
module: Generated _pb2 module
"""
# pylint: disable=g-import-not-at-top
from google.protobuf import service as _service
from google.protobuf import service_reflection
# pylint: enable=g-import-not-at-top
for (name, service) in file_des.services_by_name.items():
module[name] = service_reflection.GeneratedServiceType(
name, (_service.Service,),
name, (),
dict(DESCRIPTOR=service, __module__=module_name))
stub_name = name + '_Stub'
module[stub_name] = service_reflection.GeneratedServiceStubType(

@ -19,6 +19,14 @@ and can avoid unnecessary layers of indirection.
__author__ = 'petar@google.com (Petar Petrov)'
import warnings
warnings.warn(
'google.protobuf.service module is deprecated. RPC implementations '
'should provide code generator plugins which generate code specific to '
'the RPC implementation. service.py will be removed in Jan 2025',
stacklevel=2,
)
class RpcException(Exception):
"""Exception raised on failed blocking RPC method call."""

Loading…
Cancel
Save