-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set _max_workers in ThreadPoolExecutor with non-None initializer (…
…#1254) * Add _max_workers definition to ThreadPoolExecutor when arg is not None * Add test for ThreadPoolExecutor for None and 1 max_workers * style: pre-commit fixes --------- Co-authored-by: Nick Manganelli <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
599984e
commit 0a997cd
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
import skhep_testdata | ||
|
||
import uproot | ||
|
||
pytest.importorskip("pandas") | ||
|
||
|
||
def test_decompression_threadpool_executor_for_dask(): | ||
|
||
class TestThreadPoolExecutor(uproot.source.futures.ThreadPoolExecutor): | ||
def __init__(self, max_workers=None): | ||
super().__init__(max_workers=max_workers) | ||
self.submit_count = 0 | ||
|
||
def submit(self, task, /, *args, **kwargs): | ||
self.submit_count += 1 | ||
super().submit(task, *args, **kwargs) | ||
|
||
implicitexecutor = TestThreadPoolExecutor(max_workers=None) | ||
|
||
a = uproot.dask( | ||
{skhep_testdata.data_path("uproot-sample-6.20.04-uncompressed.root"): "sample"}, | ||
decompression_executor=implicitexecutor, | ||
) | ||
|
||
a["i4"].compute() | ||
|
||
assert implicitexecutor.max_workers > 0 | ||
|
||
assert implicitexecutor.submit_count > 0 | ||
|
||
explicitexecutor = TestThreadPoolExecutor(max_workers=1) | ||
|
||
b = uproot.dask( | ||
{skhep_testdata.data_path("uproot-sample-6.20.04-uncompressed.root"): "sample"}, | ||
decompression_executor=explicitexecutor, | ||
) | ||
|
||
b["i4"].compute() | ||
|
||
assert explicitexecutor.max_workers == 1 | ||
|
||
assert explicitexecutor.submit_count > 0 |