File tree 3 files changed +13
-4
lines changed
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ def _get_thread_pool_executor(n_workers: int) -> Executor:
84
84
class ParallelBackend (Enum ):
85
85
"""Choices for parallel backends."""
86
86
87
+ NONE = "none"
88
+
87
89
CUSTOM = "custom"
88
90
DASK = "dask"
89
91
LOKY = "loky"
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None:
26
26
["--parallel-backend" ],
27
27
type = EnumChoice (ParallelBackend ),
28
28
help = "Backend for the parallelization." ,
29
- default = ParallelBackend .LOKY ,
29
+ default = ParallelBackend .NONE ,
30
30
),
31
31
]
32
32
cli .commands ["build" ].params .extend (additional_parameters )
Original file line number Diff line number Diff line change @@ -21,9 +21,6 @@ def pytask_parse_config(config: dict[str, Any]) -> None:
21
21
"""Parse the configuration."""
22
22
__tracebackhide__ = True
23
23
24
- if config ["n_workers" ] == "auto" :
25
- config ["n_workers" ] = max (os .cpu_count () - 1 , 1 )
26
-
27
24
try :
28
25
config ["parallel_backend" ] = ParallelBackend (config ["parallel_backend" ])
29
26
except ValueError :
@@ -33,6 +30,13 @@ def pytask_parse_config(config: dict[str, Any]) -> None:
33
30
)
34
31
raise ValueError (msg ) from None
35
32
33
+ if config ["n_workers" ] == "auto" :
34
+ config ["n_workers" ] = max (os .cpu_count () - 1 , 1 )
35
+
36
+ # If more than one worker is used, and no backend is set, use loky.
37
+ if config ["n_workers" ] > 1 and config ["parallel_backend" ] == ParallelBackend .NONE :
38
+ config ["parallel_backend" ] = ParallelBackend .LOKY
39
+
36
40
config ["delay" ] = 0.1
37
41
38
42
@@ -43,6 +47,9 @@ def pytask_post_parse(config: dict[str, Any]) -> None:
43
47
if config ["pdb" ] or config ["trace" ] or config ["dry_run" ]:
44
48
return
45
49
50
+ if config ["parallel_backend" ] == ParallelBackend .NONE :
51
+ return
52
+
46
53
# Register parallel execute and logging hook.
47
54
config ["pm" ].register (logging )
48
55
config ["pm" ].register (execute )
You can’t perform that action at this time.
0 commit comments