Skip to content

Commit

Permalink
resolve issue 612
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoscon committed Aug 26, 2018
1 parent 4d19167 commit 4a3648a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arctic/_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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]
Expand Down

0 comments on commit 4a3648a

Please sign in to comment.