0

So I was just curious about the multiprocessing library in python. If I did something like

 results = pool.map(multi_run_wrapper,[(1,2),(2,3),(3,4)])

If in my function I declare global variables, are they maintained to the specific instance, or since they are global they could screw with eachother over the several different calls when running simultaneously?

I was hoping that one call would have its own namespace, etc so that there wasn't this interaction between the different calls.

Eigenvalue
  • 1,093
  • 1
  • 14
  • 35
  • 2
    As far as I know, when using multiprocessing, each Process has its own copy of the program and data. – quamrana May 19 '19 at 19:55
  • docs - https://docs.python.org/3/library/multiprocessing.html#sharing-state-between-processes interesting article with tech details https://eli.thegreenplace.net/2012/01/04/shared-counter-with-pythons-multiprocessing – El Ruso May 19 '19 at 19:57
  • 1
    Possible duplicate of [Python multiprocessing global variable updates not returned to parent](https://stackoverflow.com/questions/11055303/python-multiprocessing-global-variable-updates-not-returned-to-parent) – El Ruso May 19 '19 at 20:00
  • Did you try it? – wwii May 19 '19 at 21:17

0 Answers0