From 4a3648a1ad35f63a35a78c1d72c137eaced19eea Mon Sep 17 00:00:00 2001 From: Bryant Moscon Date: Sun, 26 Aug 2018 07:42:56 -0400 Subject: [PATCH] resolve issue 612 --- arctic/_compression.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arctic/_compression.py b/arctic/_compression.py index 8e2d7b1a6..54ee14fe0 100644 --- a/arctic/_compression.py +++ b/arctic/_compression.py @@ -28,7 +28,7 @@ # Enable this when you run the benchmark_lz4.py BENCHMARK_MODE = False -_compress_thread_pool = ThreadPool(LZ4_WORKERS) +_compress_thread_pool = None def enable_parallel_lz4(mode): @@ -86,6 +86,7 @@ def compress_array(str_list, withHC=LZ4_HIGH_COMPRESSION): `list[str` The list of the compressed strings. """ + global _compress_thread_pool if not str_list: return str_list @@ -95,6 +96,8 @@ def compress_array(str_list, withHC=LZ4_HIGH_COMPRESSION): len(str_list) > LZ4_N_PARALLEL and len(str_list[0]) > LZ4_MINSZ_PARALLEL if BENCHMARK_MODE or use_parallel: + if _compress_thread_pool is None: + _compress_thread_pool = ThreadPool(LZ4_WORKERS) return _compress_thread_pool.map(do_compress, str_list) return [do_compress(s) for s in str_list]