UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
385 stars 84 forks source link

net.shortest_paths doesn't work with multiprocessing #176

Open lilianmarey opened 2 years ago

lilianmarey commented 2 years ago

Hi,

I'm having a little of trouble trying to use Pandana with multiprocessing

Description of the bug

When I call net.shortest_paths (with an 's') in a multiprocessing process (I use a multiprocessing.Pool object), it doesn't finish like an infinite loop (no error message). I tested to do the same with net.shortest_path (without an 's') and it worked! However I have to use shortest_paths because it is faster in my case. I wanted to know if there is an explanation to this.

Network data (optional)

OpenStreetMap Data

Environment

Mac OS 11.2.1 Python 3.9.7 Pandana 0.6.1

Paste the code that reproduces the issue here:

from multiprocessing import Pool

n_cores = 3

def f(n_repet): return [net.shortest_paths([node_0_id], [node_1_id]) for i in tqdm(range(n_repet))]

p = Pool(n_cores) a = p.map(f, [10 for i in range(10)])

Thanks for your help!