From 998707ac20c5caa9683542f6f9a969a94adc79c3 2017-01-13 14:17:25 From: Thomas Kluyver Date: 2017-01-13 14:17:25 Subject: [PATCH] Skip scanning for module names with no global shell instance Closes gh-9798 --- diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py index 5aa3686..4c4357c 100644 --- a/IPython/core/completerlib.py +++ b/IPython/core/completerlib.py @@ -110,6 +110,11 @@ def get_root_modules(): ip.db['rootmodules_cache'] maps sys.path entries to list of modules. """ ip = get_ipython() + if ip is None: + # No global shell instance to store cached list of modules. + # Don't try to scan for modules every time. + return list(sys.builtin_module_names) + rootmodules_cache = ip.db.get('rootmodules_cache', {}) rootmodules = list(sys.builtin_module_names) start_time = time()