diff --git a/nonos/main.py b/nonos/main.py index 1f1d9443..03c852ce 100644 --- a/nonos/main.py +++ b/nonos/main.py @@ -46,7 +46,7 @@ import importlib_resources -# process function for parallisation purpose with progress bar +# process function for parallelisation purpose with progress bar # counterParallel = Value('i', 0) # initialization of a counter def process_field( on, @@ -540,14 +540,18 @@ def mytrack(iterable, *args, **kwargs): # noqa: ARG001 logger.info("Starting main loop") tstart = time.time() - with Pool(ncpu) as pool: - list( - mytrack( - pool.imap(func, args["on"]), - description="Processing snapshots", - total=len(args["on"]), + if ncpu == 1: + for on in args["on"]: + func(on) + else: + with Pool(ncpu) as pool: + list( + mytrack( + pool.imap(func, args["on"]), + description="Processing snapshots", + total=len(args["on"]), + ) ) - ) if not show: logger.info("Operation took {:.2f}s", time.time() - tstart) diff --git a/tests/test_plotting.py b/tests/test_plotting.py index e33852d3..1409cd71 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -190,7 +190,7 @@ def test_pbar(simulation_dir, capsys, tmp_path): out, err = capsys.readouterr() assert err == "" - assert "Processing snapshots" in out + assert out == "" assert ret == 0