From fab64a3e08809c0c490d36a8ebac354c67a1e4c3 2011-06-24 19:14:36 From: MinRK Date: 2011-06-24 19:14:36 Subject: [PATCH] prevent infinite Controllers on Windows console scripts built by non-distribute setuptools don't have `if __name__ == 'main'`, which means the outer block gets called in every child, creating infinite controllers and children. This adds a test inside the entry point, in case setuptools built a bad script. --- diff --git a/IPython/parallel/apps/ipcontrollerapp.py b/IPython/parallel/apps/ipcontrollerapp.py index 8597a32..b89ec35 100755 --- a/IPython/parallel/apps/ipcontrollerapp.py +++ b/IPython/parallel/apps/ipcontrollerapp.py @@ -405,6 +405,19 @@ class IPControllerApp(BaseParallelApplication): def launch_new_instance(): """Create and run the IPython controller""" + if sys.platform == 'win32': + # make sure we don't get called from a multiprocessing subprocess + # this can result in infinite Controllers being started on Windows + # which doesn't have a proper fork, so multiprocessing is wonky + + # this only comes up when IPython has been installed using vanilla + # setuptools, and *not* distribute. + import inspect + for record in inspect.stack(): + frame = record[0] + if frame.f_locals.get('__name__') == '__parents_main__': + # we are a subprocess, don't start another Controller! + return app = IPControllerApp.instance() app.initialize() app.start()