fork download
  1. #!/usr/bin/env python
  2. import multiprocessing as mp
  3.  
  4. def main():
  5. m = mp.Manager()
  6. d = m.dict()
  7. d[1] = m.list()
  8. d[2] = []
  9. d[3] = []
  10. d[4] = m.list()
  11. p = mp.Process(target=f, args=(d,))
  12. p.start()
  13. p.join()
  14. print(d)
  15.  
  16. def f(d):
  17. d[1].append(1)
  18. d[2] += [2]
  19. d[3].append(3)
  20. d[4] += [4]
  21. print(d)
  22.  
  23. if __name__=="__main__":
  24. mp.freeze_support()
  25. main()
  26.  
Success #stdin #stdout 0.06s 34432KB
stdin
Standard input is empty
stdout
{1: [], 2: [2], 3: [], 4: [4]}
{1: [], 2: [2], 3: [], 4: [4]}