From 7bc3a2fe2cd7047ce2efe5c9fa75088c97a241d1 2008-03-10 21:18:17 From: Ville M. Vainio Date: 2008-03-10 21:18:17 Subject: [PATCH] MTInteractiveShell.runsource: execute code directly if worker thread is not running yet (this is the case in config files) --- diff --git a/IPython/Shell.py b/IPython/Shell.py index 40df684..74a5bb0 100644 --- a/IPython/Shell.py +++ b/IPython/Shell.py @@ -408,9 +408,11 @@ class MTInteractiveShell(InteractiveShell): # section, so we have to acquire the lock with non-blocking semantics, # else we deadlock. - # shortcut - if we are in worker thread, execute directly (to allow recursion) + # shortcut - if we are in worker thread, or the worker thread is not running, + # execute directly (to allow recursion and prevent deadlock if code is run early + # in IPython construction) - if self.worker_ident == thread.get_ident(): + if self.worker_ident is None or self.worker_ident == thread.get_ident(): InteractiveShell.runcode(self,code) return