Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.parametrize("prefix", _ALL_PREFIXES)
@pytest.mark.parametrize("limit", [1, 3])
def test_threadpool_limits_by_prefix(prefix, limit):
# Check that the maximum number of threads can be set by prefix
original_info = _threadpool_info()
modules_matching_prefix = original_info.get_modules("prefix", prefix)
if not modules_matching_prefix:
pytest.skip("Requires {} runtime".format(prefix))
with threadpool_limits(limits={prefix: limit}):
for module in modules_matching_prefix:
if is_old_openblas(module):
continue
# threadpool_limits only sets an upper bound on the number of
# threads.
assert 0 < module.get_num_threads() <= limit