[Tutor] Multiprocessing

Mats Wichmann mats at wichmann.us
Fri Jul 2 11:11:13 EDT 2021


On 6/30/21 9:00 AM, Pugliese, Francesco wrote:
> Dear all,
> 
> I am Francesco and currently PhD at the University of Liverpool.
> 
> I am trying to use the multiprocessing library in python to performance some structural analyses using Opensees (please see the attached file for reference). I am coding like this:
> 
> 
> if __name__=="__main__":
>        p = Pool(8)
>        p.map(fun, range(1,10001), chunksize = 1)
>        p.terminate()
>        p.join()
> 
> 
> After completing all analyses, the system does not close the pool but remains stuck (frozen) without doing anything. Could please help me out to understand where I am making mistakes?

multiprocessing is full of traps.

as an experiment maybe try setting the start method to "spawn" and see 
if the behavior changes.  the spawn approach is considered a bit slower 
than the LInux default, but it's definitely safer; and since you're 
creating a pool it's all one-time startup cost and shouldn't be an issue.



More information about the Tutor mailing list