diff options
author | Nathaniel Manista <nathaniel@google.com> | 2017-01-17 15:00:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-17 15:00:34 -0800 |
commit | fc4b07e10c0482522dbc6a01401ea8f1606a76b4 (patch) | |
tree | 622b321c1682d85950c8b9519c2f957b26e6e52e /src/python/grpcio_tests/tests/unit/_thread_pool.py | |
parent | c0d7d67dfbe4f7d539e64365c4111b748285668f (diff) | |
parent | cc793703bfba6f661f523b6fec82ff8a913e1759 (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.py | 25 |
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 |