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