use isinstance for internal api to not catch mocks

pull/18172/head
Eric Gribkoff 6 years ago
parent b7ee2d9bdb
commit 1c2303c635
  1. 5
      src/python/grpcio/grpc/_server.py
  2. 2
      src/python/grpcio_tests/tests/unit/thread_pool.py

@ -19,6 +19,7 @@ import logging
import threading
import time
from concurrent import futures
import six
import grpc
@ -565,8 +566,8 @@ def _send_message_callback_to_blocking_iterator_adapter(
def _select_thread_pool_for_behavior(behavior, default_thread_pool):
if hasattr(behavior, 'experimental_thread_pool'
) and behavior.experimental_thread_pool is not None:
if hasattr(behavior, 'experimental_thread_pool') and isinstance(
behavior.experimental_thread_pool, futures.ThreadPoolExecutor):
return behavior.experimental_thread_pool
else:
return default_thread_pool

@ -16,7 +16,7 @@ import threading
from concurrent import futures
class RecordingThreadPool(futures.Executor):
class RecordingThreadPool(futures.ThreadPoolExecutor):
"""A thread pool that records if used."""
def __init__(self, max_workers):

Loading…
Cancel
Save