Remove dependency of grpc.framework.foundation.callable_util

* Used in _channel.py, _server.py, and _utilities.py
* This API can trace back to 4 years ago
* The code change ensures the logging info is exactly the same
pull/17543/head
Lidi Zheng 6 years ago
parent 1af10acdac
commit 71094e25c5
  1. 9
      src/python/grpcio/grpc/_channel.py
  2. 7
      src/python/grpcio/grpc/_server.py
  3. 16
      src/python/grpcio/grpc/_utilities.py

@ -22,7 +22,6 @@ import grpc
from grpc import _common
from grpc import _grpcio_metadata
from grpc._cython import cygrpc
from grpc.framework.foundation import callable_util
_LOGGER = logging.getLogger(__name__)
@ -871,9 +870,11 @@ def _deliver(state, initial_connectivity, initial_callbacks):
while True:
for callback in callbacks:
cygrpc.block_if_fork_in_progress(state)
callable_util.call_logging_exceptions(
callback, _CHANNEL_SUBSCRIPTION_CALLBACK_ERROR_LOG_MESSAGE,
connectivity)
try:
callback(connectivity)
except Exception: # pylint: disable=broad-except
_LOGGER.exception(
_CHANNEL_SUBSCRIPTION_CALLBACK_ERROR_LOG_MESSAGE)
with state.lock:
callbacks = _deliveries(state)
if callbacks:

@ -25,7 +25,6 @@ import grpc
from grpc import _common
from grpc import _interceptor
from grpc._cython import cygrpc
from grpc.framework.foundation import callable_util
_LOGGER = logging.getLogger(__name__)
@ -748,8 +747,10 @@ def _process_event_and_continue(state, event):
else:
rpc_state, callbacks = event.tag(event)
for callback in callbacks:
callable_util.call_logging_exceptions(callback,
'Exception calling callback!')
try:
callback()
except Exception: # pylint: disable=broad-except
_LOGGER.exception('Exception calling callback!')
if rpc_state is not None:
with state.lock:
state.rpc_states.remove(rpc_state)

@ -16,12 +16,14 @@
import collections
import threading
import time
import logging
import six
import grpc
from grpc import _common
from grpc.framework.foundation import callable_util
_LOGGER = logging.getLogger(__name__)
_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE = (
'Exception calling connectivity future "done" callback!')
@ -98,8 +100,10 @@ class _ChannelReadyFuture(grpc.Future):
return
for done_callback in done_callbacks:
callable_util.call_logging_exceptions(
done_callback, _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE, self)
try:
done_callback(self)
except Exception: # pylint: disable=broad-except
_LOGGER.exception(_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)
def cancel(self):
with self._condition:
@ -113,8 +117,10 @@ class _ChannelReadyFuture(grpc.Future):
return False
for done_callback in done_callbacks:
callable_util.call_logging_exceptions(
done_callback, _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE, self)
try:
done_callback(self)
except Exception: # pylint: disable=broad-except
_LOGGER.exception(_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)
return True

Loading…
Cancel
Save