Back to main.

Calmcode Shorts

parallel logoparallel

Installation

You can learn more about parallel by checking their documentation page.

If you're on a mac you can install the tool via;

brew install parallel

On many linux distributions you should be able to install it via;

apt-get install parallel

You can confirm the installation command for your linux distribution.

Usage

The demo.py file in this video has the following contents.

import sys
import time

if __name__ == "__main__":
    i = int(sys.argv[1])
    time.sleep(0.1)
    print(f"these are the input settings: {sys.argv}")

If you want to run this file sequentially you can use xargs.

seq 10 | xargs -n 1 python demo.py

If you want to run it in parallel, you should use parallel instead.

seq 50 | parallel -j 12 python demo.py

Back to main.