pw_tokenizer: Check _pool before using it
test_invalid_domain_specification causes an exception to occur
before allocating _pool. Check if _pool is allocated before
using it.
Change-Id: I0cf9047d8a2f04e0eaeca44f7a579f70bdf0af80
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/252813
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Commit-Queue: Al Semjonovs <asemjonovs@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Al Semjonovs <asemjonovs@google.com>
Docs-Not-Needed: Al Semjonovs <asemjonovs@google.com>
diff --git a/pw_tokenizer/py/pw_tokenizer/detokenize.py b/pw_tokenizer/py/pw_tokenizer/detokenize.py
index f95d2e5..18db169 100755
--- a/pw_tokenizer/py/pw_tokenizer/detokenize.py
+++ b/pw_tokenizer/py/pw_tokenizer/detokenize.py
@@ -537,7 +537,8 @@
super().__init__(*(path.load() for path in self.paths), prefix=prefix)
def __del__(self) -> None:
- self._pool.shutdown(wait=False)
+ if hasattr(self, '_pool'):
+ self._pool.shutdown(wait=False)
def _reload_paths(self) -> None:
self._initialize_database([path.load() for path in self.paths])