title: Multiprocessing, dynamic nested manager not working in windows (fine on Macs)
body: <p>This is a vastly simplified version of running threads within threads where I call various groups of apis separately.Sometimes the groups will be run sequentially, sometimes simultaneously..below is the simplified code that works just fine on a mac:</p>
  <pre><code>from multiprocessing import Process, Manager
  
  def test(index):
      my_dict[index] = manager.dict()
      my_dict[index]['status'] = 200
  
  def collate_tests():
      apis = []
      for i in range(10):
          apis.append(Process(target=test, args=(f&quot;{i}&quot;,)))
  
  for index, value in enumerate(apis):
      print (f&quot;Execute {index +1} of {len(apis)} Tests&quot;)
      value.start()
  
  for api in apis:
      api.join()
  
  
  if __name__ == '__main__':
      manager = Manager()
      my_dict = manager.dict()
      run_test = Process(target=collate_tests)
  
      run_test.start()
      run_test.join()
  
      for k,v in my_dict.items():
          print (k,v)
  </code></pre>
  <p>I get the result</p>
  <pre><code>0 {'status': 200}
  1 {'status': 200}
  2 {'status': 200}
  4 {'status': 200}
  3 {'status': 200}
  5 {'status': 200}
  6 {'status': 200}
  7 {'status': 200}
  9 {'status': 200}
  8 {'status': 200}
  </code></pre>
  <p>In windows i get</p>
  <pre><code>NameError: name ‘my_dict’ is not defined
  </code></pre>
  <p>So I pass my_dict as args and then i get :</p>
  <pre><code>NameError: name ‘manager’ is not defined
  </code></pre>
  <p>If I pass manager as an arguments</p>
  <pre><code>TypeError : can’t pickle weakref objects
  </code></pre>
  <p>So i can't seem to set this line anyhow</p>
  <pre><code>my_dict = manager.dict()
  </code></pre>
  <p>I even tried instantiating another manager in the test() method. But that got me nowhere either as i couldn't iterate the dict proxy that created. Any suggestions?</p>
  <p>Note the standard way of setting the nested managers in</p>
  <pre><code>if __name__ == '__main__':
  </code></pre>
  <p>Is not feasible as I don't have any idea what 'index' my_dict[index] will be ahead of time. Is what I'm attempting even possible in Windows?</p>
  <p>PS - I have scoured the web but didn't quite find the solution i was looking for. Thanks</p>