|
|
@ -105,6 +105,7 @@ def calculate_distance(pair): |
|
|
|
distance = get_distance(city1["name"], city2["name"]) |
|
|
|
return city1["name"], city2["name"], distance |
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
cities = list(us_cities.values()) |
|
|
|
print(f"Num cities: {len(cities)}") |
|
|
@ -121,7 +122,7 @@ def main(): |
|
|
|
try: |
|
|
|
executor = concurrent.futures.ProcessPoolExecutor(max_workers=args.workers) |
|
|
|
for i in range(num_chunks): |
|
|
|
chunk = city_combinations[i * chunk_size : (i + 1) * chunk_size] |
|
|
|
chunk = city_combinations[(i * chunk_size) : (i + 1) * chunk_size] |
|
|
|
futures = { |
|
|
|
executor.submit(calculate_distance, pair): pair for pair in chunk |
|
|
|
} |
|
|
|