aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_tests/tests/unit/_thread_pool.py
diff options
context:
space:
mode:
authorGravatar Nathaniel Manista <nathaniel@google.com>2017-01-17 15:00:34 -0800
committerGravatar GitHub <noreply@github.com>2017-01-17 15:00:34 -0800
commitfc4b07e10c0482522dbc6a01401ea8f1606a76b4 (patch)
tree622b321c1682d85950c8b9519c2f957b26e6e52e /src/python/grpcio_tests/tests/unit/_thread_pool.py
parentc0d7d67dfbe4f7d539e64365c4111b748285668f (diff)
parentcc793703bfba6f661f523b6fec82ff8a913e1759 (diff)
Merge pull request #9276 from soltanmm-google/remember-the-blue-flowers-they-are-important!
Enable yapf (Python formatting).
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