Skip to content

Commit

Permalink
More parallel testing
Browse files Browse the repository at this point in the history
  • Loading branch information
burggraaff committed Mar 7, 2024
1 parent 5710492 commit a7f3033
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion fpcup/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from datetime import date, datetime
from itertools import product
from multiprocessing import Pool # Multi-threading
from multiprocessing import Pool
from pathlib import Path

import geopandas as gpd
Expand Down
19 changes: 0 additions & 19 deletions legacy/test_tqdm_parallel.py

This file was deleted.

27 changes: 27 additions & 0 deletions test/tqdm_parallel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Testing multiprocessing + tqdm
https://stackoverflow.com/q/41920124/2229219
"""
from multiprocessing import cpu_count, freeze_support
from multiprocessing import Pool
from tqdm import tqdm

def parse_args():
import argparse
parser = argparse.ArgumentParser(description="Test multiprocessing stuff.")
parser.add_argument("-n", "--number", help="number of iterations", type=int, default=7000000)
args = parser.parse_args()
return args

def _foo(my_number):
square = my_number * my_number
return square, square

if __name__ == '__main__':
freeze_support()
print(f"CPU count: {cpu_count()}")

args = parse_args()

with Pool() as p:
r1, r2 = zip(*tqdm(p.imap(_foo, range(args.number), chunksize=500), total=args.number))

0 comments on commit a7f3033

Please sign in to comment.