Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parallel processing
On Thu, Mar 24, 2022 at 9:34 PM Perry Smith <pedz@xxxxxxxxxxxxxxxx> wrote:
>
> Has something like prll (parallel) https://github.com/exzombie/prll been added to zsh?
Look at the "zargs" function, -P option (which works like "xargs -P"
for the most part).
Silly example:
autoload zargs
zmodload zsh/system
zargs -n 2 -P 4 -- {1..20} -- eval '() { print $1 $sysparams[pid]; sleep 2 }'
Note you need -n 2 there because the first "word" is the argument to
eval and the second "word" is the successive integer from the list 1
through 20.
This isn't exactly what you want because it waits for all four jobs
before starting the next batch, but keeping a specific number of
children running is not straightforward with the job-management
operations available to a shell.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author