diff -r 44ebac378e51 Lib/multiprocessing/forking.py --- a/Lib/multiprocessing/forking.py Wed Feb 27 10:04:23 2013 -0800 +++ b/Lib/multiprocessing/forking.py Wed Feb 27 14:55:50 2013 -0500 @@ -438,7 +438,7 @@ elif main_name != 'ipython': # Main modules not actually called __main__.py may # contain additional code that should still be executed - import imp + import importlib if main_path is None: dirs = None @@ -449,16 +449,12 @@ assert main_name not in sys.modules, main_name sys.modules.pop('__mp_main__', None) - file, path_name, etc = imp.find_module(main_name, dirs) - try: - # We should not do 'imp.load_module("__main__", ...)' - # since that would execute 'if __name__ == "__main__"' - # clauses, potentially causing a psuedo fork bomb. - main_module = imp.load_module( - '__mp_main__', file, path_name, etc - ) - finally: - if file: - file.close() + loader = importlib.find_loader(main_name, dirs) + # We should not do 'loader.load_module("__main__", ...)' + # since that would execute 'if __name__ == "__main__"' + # clauses, potentially causing a psuedo fork bomb. + loader.load_module(main_name) + # Old loaders may not return the module from load_module(). + main_module = sys.modules[main_name] sys.modules['__main__'] = sys.modules['__mp_main__'] = main_module