Skip to content

Commit c1e0902

Browse files
committed
allow parallel_threads_limit('auto') for compatibility
1 parent 1121cc9 commit c1e0902

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/pytest_run_parallel/utils.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ def get_configured_num_workers(config):
1111
return n_workers
1212

1313

14+
def auto_or_int(val):
15+
if val == "auto":
16+
logical_cpus = get_logical_cpus()
17+
return logical_cpus if logical_cpus is not None else 1
18+
return int(val)
19+
20+
1421
def get_num_workers(item):
1522
n_workers = get_configured_num_workers(item.config)
1623
# TODO: deprecate in favor of parallel_threads_limit
1724
marker_used = False
1825
marker = item.get_closest_marker("parallel_threads")
1926
if marker is not None:
2027
marker_used = True
21-
val = marker.args[0]
22-
if val == "auto":
23-
logical_cpus = get_logical_cpus()
24-
n_workers = logical_cpus if logical_cpus is not None else 1
25-
else:
26-
n_workers = int(val)
28+
n_workers = auto_or_int(marker.args[0])
2729
limit_marker = item.get_closest_marker("parallel_threads_limit")
2830
if limit_marker is not None:
29-
val = int(limit_marker.args[0])
31+
val = auto_or_int(limit_marker.args[0])
3032
if val == 1:
3133
marker_used = True
3234
if n_workers > val:

0 commit comments

Comments
 (0)