I am writing a class that supports easy-to-use API to add different settings to run a given program (class.add(args)
) and to benchmark all settings with multiprocessing (class.benchmark(num_processes=5)
).
From the documentation of multiprocessing.Process, it seems all cases using if __name__ == '__main__'
. Is it safe to skip using it ?
For example, the class method benchmark(num_processes=5)
starts and joins processes, and another python file file.py
creates a class and simply call class.benchmark(num_processes=5)
. Will it work as usual ?