aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_tests/tests/unit/_thread_pool.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio_tests/tests/unit/_thread_pool.py')
-rw-r--r--src/python/grpcio_tests/tests/unit/_thread_pool.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/python/grpcio_tests/tests/unit/_thread_pool.py b/src/python/grpcio_tests/tests/unit/_thread_pool.py
index f13cc2f86f..fad2e1c8f6 100644
--- a/src/python/grpcio_tests/tests/unit/_thread_pool.py
+++ b/src/python/grpcio_tests/tests/unit/_thread_pool.py
@@ -32,17 +32,18 @@ from concurrent import futures
class RecordingThreadPool(futures.Executor):
- """A thread pool that records if used."""
- def __init__(self, max_workers):
- self._tp_executor = futures.ThreadPoolExecutor(max_workers=max_workers)
- self._lock = threading.Lock()
- self._was_used = False
+ """A thread pool that records if used."""
- def submit(self, fn, *args, **kwargs):
- with self._lock:
- self._was_used = True
- self._tp_executor.submit(fn, *args, **kwargs)
+ def __init__(self, max_workers):
+ self._tp_executor = futures.ThreadPoolExecutor(max_workers=max_workers)
+ self._lock = threading.Lock()
+ self._was_used = False
- def was_used(self):
- with self._lock:
- return self._was_used
+ def submit(self, fn, *args, **kwargs):
+ with self._lock:
+ self._was_used = True
+ self._tp_executor.submit(fn, *args, **kwargs)
+
+ def was_used(self):
+ with self._lock:
+ return self._was_used