Print exception trace for functions submitted to thread_pool (#32030)

* Print exception trace in thread_pool

* Fix sanity test

* fix format

* Change traceback.print_exception to traceback.print_exc
pull/32131/head
Xuan Wang 2 years ago committed by GitHub
parent e7b5499ca8
commit 829eb8f98a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/python/grpcio/grpc/_server.py

@ -21,6 +21,7 @@ import enum
import logging
import threading
import time
import traceback
from typing import (Any, Callable, Iterable, Iterator, List, Mapping, Optional,
Sequence, Set, Tuple, Union)
@ -624,6 +625,8 @@ def _unary_response_in_pool(
rpc_event, state, response, response_serializer)
if serialized_response is not None:
_status(rpc_event, state, serialized_response)
except Exception: # pylint: disable=broad-except
traceback.print_exc()
finally:
cygrpc.uninstall_context()
@ -662,6 +665,8 @@ def _stream_response_in_pool(
if proceed:
_send_message_callback_to_blocking_iterator_adapter(
rpc_event, state, send_response, response_iterator)
except Exception: # pylint: disable=broad-except
traceback.print_exc()
finally:
cygrpc.uninstall_context()

Loading…
Cancel
Save