Note wait with no arguments paits for all background jobs. With a PID or job spec, it waits for just that one. Useful in scripts to parallelize tasks and then synchronize before continuing.
Note TaskGroup replaces asyncio.gather() with structured concurrency. If any task raises, all other tasks are cancelled and errors are collected into an ExceptionGroup.
Frequently asked questions
How does Bash & Linux handle parallel tasks?
This task is covered in 2 stacks on this page: Bash & Linux, Python. The "Wait for Background Jobs" snippet in Bash & Linux uses `wait [pid|%job]`.
Which command does the Bash & Linux example use?
The "Wait for Background Jobs" snippet uses `wait [pid|%job]`, from the Process Management section of the Bash & Linux cheat sheet.
Which stacks cover "parallel tasks" on this page?
Bash & Linux, Python. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Wait for Background Jobs": wait with no arguments paits for all background jobs. With a PID or job spec, it waits for just that one. Useful in scripts to parallelize tasks and then synchronize before continuing.