Reloading a Python module per process in the multiprocessing module : <p>Is there a way to load per-process copies of modules in processes created using Python's multiprocessing module? I tried this:</p>

<pre><code>def my_fn(process_args):
    import my_module
    my_func()
</code></pre>

<p>...but the sub-imports in my_module get loaded and cached once and for all. In particular, one of the sub-imports reads a config file whose values get set based on the environment of the first process. If I try this:</p>

<pre><code>def my_fn(process_args):
    try:
        my_module = reload(my_module)
    except NameError:
        import my_module
</code></pre>

<p>...the sub-imports of my_module do not get reloaded.</p>
