Show More
@@ -46,11 +46,11 b' def get_connection_file(app=None):' | |||||
46 | If unspecified, the currently running app will be used |
|
46 | If unspecified, the currently running app will be used | |
47 | """ |
|
47 | """ | |
48 | if app is None: |
|
48 | if app is None: | |
49 |
from IPython.zmq.kernel |
|
49 | from IPython.zmq.ipkernel import IPKernelApp | |
50 | if not KernelApp.initialized(): |
|
50 | if not IPKernelApp.initialized(): | |
51 | raise RuntimeError("app not specified, and not in a running Kernel") |
|
51 | raise RuntimeError("app not specified, and not in a running Kernel") | |
52 |
|
52 | |||
53 | app = KernelApp.instance() |
|
53 | app = IPKernelApp.instance() | |
54 | return filefind(app.connection_file, ['.', app.profile_dir.security_dir]) |
|
54 | return filefind(app.connection_file, ['.', app.profile_dir.security_dir]) | |
55 |
|
55 | |||
56 | def find_connection_file(filename, profile=None): |
|
56 | def find_connection_file(filename, profile=None): |
@@ -38,4 +38,25 b' from .client.view import *' | |||||
38 | from .util import interactive |
|
38 | from .util import interactive | |
39 | from .controller.dependency import * |
|
39 | from .controller.dependency import * | |
40 |
|
40 | |||
|
41 | #----------------------------------------------------------------------------- | |||
|
42 | # Functions | |||
|
43 | #----------------------------------------------------------------------------- | |||
|
44 | ||||
|
45 | ||||
|
46 | def bind_kernel(**kwargs): | |||
|
47 | """Bind an Engine's Kernel to be used as a full IPython kernel. | |||
|
48 | ||||
|
49 | This allows a running Engine to be used simultaneously as a full IPython kernel | |||
|
50 | with the QtConsole or other frontends. | |||
|
51 | ||||
|
52 | This function returns immediately. | |||
|
53 | """ | |||
|
54 | from IPython.parallel.apps.ipengineapp import IPEngineApp | |||
|
55 | if IPEngineApp.initialized(): | |||
|
56 | app = IPEngineApp.instance() | |||
|
57 | else: | |||
|
58 | raise RuntimeError("Must be called from an IPEngineApp instance") | |||
|
59 | ||||
|
60 | return app.bind_kernel(**kwargs) | |||
|
61 | ||||
41 |
|
62 |
@@ -230,19 +230,25 b' class IPEngineApp(BaseParallelApplication):' | |||||
230 | except AttributeError: |
|
230 | except AttributeError: | |
231 | config.EngineFactory.sshserver = d['ssh'] |
|
231 | config.EngineFactory.sshserver = d['ssh'] | |
232 |
|
232 | |||
233 |
def |
|
233 | def bind_kernel(self, **kwargs): | |
234 |
""" |
|
234 | """Promote engine to listening kernel, accessible to frontends.""" | |
235 | if self.kernel_app is not None: |
|
235 | if self.kernel_app is not None: | |
236 | return |
|
236 | return | |
237 |
|
237 | |||
238 | self.log.info("Opening ports for direct connections") |
|
238 | self.log.info("Opening ports for direct connections as an IPython kernel") | |
239 |
|
239 | |||
240 | kernel = self.kernel |
|
240 | kernel = self.kernel | |
241 |
|
241 | |||
242 | app = self.kernel_app = IPKernelApp(log=self.log, config=self.config, |
|
242 | kwargs.setdefault('config', self.config) | |
243 | profile_dir = self.profile_dir, |
|
243 | kwargs.setdefault('log', self.log) | |
244 | session=self.engine.session, |
|
244 | kwargs.setdefault('profile_dir', self.profile_dir) | |
245 | ) |
|
245 | kwargs.setdefault('session', self.engine.session) | |
|
246 | ||||
|
247 | app = self.kernel_app = IPKernelApp(**kwargs) | |||
|
248 | ||||
|
249 | # allow IPKernelApp.instance(): | |||
|
250 | IPKernelApp._instance = app | |||
|
251 | ||||
246 | app.init_connection_file() |
|
252 | app.init_connection_file() | |
247 | # relevant contents of init_sockets: |
|
253 | # relevant contents of init_sockets: | |
248 |
|
254 |
General Comments 0
You need to be logged in to leave comments.
Login now