Esempio n. 1
0
    def _assert_ipython_dir():
        # Fix OOIION-1124:
        # When multiple containers are started in parallel, all start an embedded IPython shell/manhole.
        # There might be a race condition between the IPython creating the default $HOME/.python dir
        # leading to an error. Prevent this by...
        homedir = os.path.expanduser('~')
        homedir = os.path.realpath(homedir)
        home_ipdir = os.path.join(homedir, ".ipython")
        ipdir = os.path.normpath(os.path.expanduser(home_ipdir))
        if not os.path.exists(ipdir):
            log.warn("%s not found. Preventing potential race condition", ipdir)
            for tries in range(3):
                try:
                    import gevent
                    import random
                    gevent.sleep(random.random() * 0.1)
                    from IPython.core.application import BaseIPythonApplication
                    ba = BaseIPythonApplication()
                    ba.initialize()
                    if os.path.exists(ipdir):
                        log.debug("Success initializing IPython")
                        break
                except Exception as ex:
                    log.debug("Failed IPython initialize attempt (try #%s): %s", tries, str(ex))

        # At this point there should be
        if not os.path.exists(ipdir):
            log.error("%s not found after several tries", ipdir)
Esempio n. 2
0
 def _profile_dir_default(self):
     from IPython.core.application import BaseIPythonApplication
     app = None
     try:
         if BaseIPythonApplication.initialized():
             app = BaseIPythonApplication.instance()
     except MultipleInstanceError:
         pass
     if app is None:
         # create an app, without the global instance
         app = BaseIPythonApplication()
         app.initialize(argv=[])
     return app.profile_dir
Esempio n. 3
0
 def _profile_dir_default(self):
     from IPython.core.application import BaseIPythonApplication
     app = None
     try:
         if BaseIPythonApplication.initialized():
             app = BaseIPythonApplication.instance()
     except MultipleInstanceError:
         pass
     if app is None:
         # create an app, without the global instance
         app = BaseIPythonApplication()
         app.initialize(argv=[])
     return app.profile_dir
Esempio n. 4
0
 def initialize(self, argv=[]):
     BaseIPythonApplication.initialize(self, argv=argv)
     self.init_connection_file()
Esempio n. 5
0
 def initialize(self, argv=[]):
     BaseIPythonApplication.initialize(self, argv=argv)
     self.init_connection_file()