##// END OF EJS Templates
bind_kernel on a bound kernel is a no-op
MinRK -
Show More
@@ -1,62 +1,74 b''
1 """The IPython ZMQ-based parallel computing interface.
1 """The IPython ZMQ-based parallel computing interface.
2
2
3 Authors:
3 Authors:
4
4
5 * MinRK
5 * MinRK
6 """
6 """
7 #-----------------------------------------------------------------------------
7 #-----------------------------------------------------------------------------
8 # Copyright (C) 2011 The IPython Development Team
8 # Copyright (C) 2011 The IPython Development Team
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
13
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15 # Imports
15 # Imports
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 import os
18 import os
19 import warnings
19 import warnings
20
20
21 import zmq
21 import zmq
22
22
23 from IPython.config.configurable import MultipleInstanceError
23 from IPython.zmq import check_for_zmq
24 from IPython.zmq import check_for_zmq
24
25
25 if os.name == 'nt':
26 if os.name == 'nt':
26 min_pyzmq = '2.1.7'
27 min_pyzmq = '2.1.7'
27 else:
28 else:
28 min_pyzmq = '2.1.4'
29 min_pyzmq = '2.1.4'
29
30
30 check_for_zmq(min_pyzmq, 'IPython.parallel')
31 check_for_zmq(min_pyzmq, 'IPython.parallel')
31
32
32 from IPython.utils.pickleutil import Reference
33 from IPython.utils.pickleutil import Reference
33
34
34 from .client.asyncresult import *
35 from .client.asyncresult import *
35 from .client.client import Client
36 from .client.client import Client
36 from .client.remotefunction import *
37 from .client.remotefunction import *
37 from .client.view import *
38 from .client.view import *
38 from .util import interactive
39 from .util import interactive
39 from .controller.dependency import *
40 from .controller.dependency import *
40
41
41 #-----------------------------------------------------------------------------
42 #-----------------------------------------------------------------------------
42 # Functions
43 # Functions
43 #-----------------------------------------------------------------------------
44 #-----------------------------------------------------------------------------
44
45
45
46
46 def bind_kernel(**kwargs):
47 def bind_kernel(**kwargs):
47 """Bind an Engine's Kernel to be used as a full IPython kernel.
48 """Bind an Engine's Kernel to be used as a full IPython kernel.
48
49
49 This allows a running Engine to be used simultaneously as a full IPython kernel
50 This allows a running Engine to be used simultaneously as a full IPython kernel
50 with the QtConsole or other frontends.
51 with the QtConsole or other frontends.
51
52
52 This function returns immediately.
53 This function returns immediately.
53 """
54 """
55 from IPython.zmq.ipkernel import IPKernelApp
54 from IPython.parallel.apps.ipengineapp import IPEngineApp
56 from IPython.parallel.apps.ipengineapp import IPEngineApp
57
58 # first check for IPKernelApp, in which case this should be a no-op
59 # because there is already a bound kernel
60 if IPKernelApp.initialized() and isinstance(IPKernelApp._instance, IPKernelApp):
61 return
62
55 if IPEngineApp.initialized():
63 if IPEngineApp.initialized():
56 app = IPEngineApp.instance()
64 try:
57 else:
65 app = IPEngineApp.instance()
58 raise RuntimeError("Must be called from an IPEngineApp instance")
66 except MultipleInstanceError:
67 pass
68 else:
69 return app.bind_kernel(**kwargs)
70
71 raise RuntimeError("bind_kernel be called from an IPEngineApp instance")
59
72
60 return app.bind_kernel(**kwargs)
61
73
62
74
General Comments 0
You need to be logged in to leave comments. Login now