Re: How does this wait -n work to cap parallelism?

2019-07-29 Thread Earnestly
On Mon, Jul 29, 2019 at 07:12:42PM +0100, Earnestly wrote: > The question is about how the example works in order to maintain > parallelism capped at num_proc. Thanks to emg on #bash for explaining how what is essentially going on. Bash essentially maintains a list of completed jobs until wait -n

Re: How does this wait -n work to cap parallelism?

2019-07-29 Thread Earnestly
On Mon, Jul 29, 2019 at 02:38:48PM -0400, Greg Wooledge wrote: > The same happens for my_job 7, and my_job 8. Each one is preceded by > a wait -n, so it waits for one of the existing jobs to terminate before > the new job is launched. This aspect of the behaviour isn't in question. Without reite

Re: How does this wait -n work to cap parallelism?

2019-07-29 Thread Greg Wooledge
On Mon, Jul 29, 2019 at 07:12:42PM +0100, Earnestly wrote: > #!/usr/bin/env bash > > # number of processes to run in parallel > num_procs=5 > > # function that processes one item > my_job() { > printf 'Processing %s\n' "$1" > sleep "

How does this wait -n work to cap parallelism?

2019-07-29 Thread Earnestly
This mail was spurred on by users in the #bash IRC channel. It started after reading where the article introduces an example using 'wait -n' as a means to provide capped parallism: #!/usr/bin/env bash # number of processes to run in