##// END OF EJS Templates
check for any Application with Kernel in zmq.eventloop...
MinRK -
Show More
@@ -20,8 +20,10 b' import sys'
20 import zmq
20 import zmq
21
21
22 # Local imports.
22 # Local imports.
23 from IPython.config.application import Application
23 from IPython.utils import io
24 from IPython.utils import io
24
25
26
25 #------------------------------------------------------------------------------
27 #------------------------------------------------------------------------------
26 # Eventloops for integrating the Kernel into different GUIs
28 # Eventloops for integrating the Kernel into different GUIs
27 #------------------------------------------------------------------------------
29 #------------------------------------------------------------------------------
@@ -206,11 +208,15 b' loop_map = {'
206
208
207 def enable_gui(gui, kernel=None):
209 def enable_gui(gui, kernel=None):
208 """Enable integration with a given GUI"""
210 """Enable integration with a given GUI"""
209 if kernel is None:
210 from .ipkernel import IPKernelApp
211 kernel = IPKernelApp.instance().kernel
212 if gui not in loop_map:
211 if gui not in loop_map:
213 raise ValueError("GUI %r not supported" % gui)
212 raise ValueError("GUI %r not supported" % gui)
213 if kernel is None:
214 if Application.initialized():
215 kernel = getattr(Application.instance(), 'kernel', None)
216 if kernel is None:
217 raise RuntimeError("You didn't specify a kernel,"
218 " and no IPython Application with a kernel appears to be running."
219 )
214 loop = loop_map[gui]
220 loop = loop_map[gui]
215 if kernel.eventloop is not None and kernel.eventloop is not loop:
221 if kernel.eventloop is not None and kernel.eventloop is not loop:
216 raise RuntimeError("Cannot activate multiple GUI eventloops")
222 raise RuntimeError("Cannot activate multiple GUI eventloops")
General Comments 0
You need to be logged in to leave comments. Login now