diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 6e300ee6c5d..9224b2ac672 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.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 diff --git a/src/python/grpcio_tests/tests/unit/thread_pool.py b/src/python/grpcio_tests/tests/unit/thread_pool.py index e99efc3e927..bc0f0e523bc 100644 --- a/src/python/grpcio_tests/tests/unit/thread_pool.py +++ b/src/python/grpcio_tests/tests/unit/thread_pool.py @@ -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):