##// END OF EJS Templates
only use zmq.jsonapi when talking to zmq sockets...
MinRK -
Show More
@@ -3,6 +3,8 b''
3 3 # Copyright (c) IPython Development Team.
4 4 # Distributed under the terms of the Modified BSD License.
5 5
6 import json
7
6 8 try:
7 9 from urllib.parse import urlparse # Py 3
8 10 except ImportError:
@@ -16,8 +18,6 b' import logging'
16 18 from tornado import web
17 19 from tornado import websocket
18 20
19 from zmq.utils import jsonapi
20
21 21 from IPython.kernel.zmq.session import Session
22 22 from IPython.utils.jsonutil import date_default
23 23 from IPython.utils.py3compat import PY3, cast_unicode
@@ -73,7 +73,7 b' class ZMQStreamHandler(websocket.WebSocketHandler):'
73 73 except KeyError:
74 74 pass
75 75 msg.pop('buffers')
76 return jsonapi.dumps(msg, default=date_default)
76 return json.dumps(msg, default=date_default)
77 77
78 78 def _on_zmq_reply(self, msg_list):
79 79 # Sometimes this gets triggered when the on_close method is scheduled in the
@@ -1,25 +1,12 b''
1 """Tornado handlers for cluster web service.
1 """Tornado handlers for cluster web service."""
2 2
3 Authors:
3 # Copyright (c) IPython Development Team.
4 # Distributed under the terms of the Modified BSD License.
4 5
5 * Brian Granger
6 """
7
8 #-----------------------------------------------------------------------------
9 # Copyright (C) 2011 The IPython Development Team
10 #
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
13 #-----------------------------------------------------------------------------
14
15 #-----------------------------------------------------------------------------
16 # Imports
17 #-----------------------------------------------------------------------------
6 import json
18 7
19 8 from tornado import web
20 9
21 from zmq.utils import jsonapi
22
23 10 from ...base.handlers import IPythonHandler
24 11
25 12 #-----------------------------------------------------------------------------
@@ -31,14 +18,14 b' class MainClusterHandler(IPythonHandler):'
31 18
32 19 @web.authenticated
33 20 def get(self):
34 self.finish(jsonapi.dumps(self.cluster_manager.list_profiles()))
21 self.finish(json.dumps(self.cluster_manager.list_profiles()))
35 22
36 23
37 24 class ClusterProfileHandler(IPythonHandler):
38 25
39 26 @web.authenticated
40 27 def get(self, profile):
41 self.finish(jsonapi.dumps(self.cluster_manager.profile_info(profile)))
28 self.finish(json.dumps(self.cluster_manager.profile_info(profile)))
42 29
43 30
44 31 class ClusterActionHandler(IPythonHandler):
@@ -54,7 +41,7 b' class ClusterActionHandler(IPythonHandler):'
54 41 data = cm.start_cluster(profile, int(n))
55 42 if action == 'stop':
56 43 data = cm.stop_cluster(profile)
57 self.finish(jsonapi.dumps(data))
44 self.finish(json.dumps(data))
58 45
59 46
60 47 #-----------------------------------------------------------------------------
@@ -3,11 +3,10 b''
3 3 # Copyright (c) IPython Development Team.
4 4 # Distributed under the terms of the Modified BSD License.
5 5
6 import json
6 7 import logging
7 8 from tornado import web
8 9
9 from zmq.utils import jsonapi
10
11 10 from IPython.utils.jsonutil import date_default
12 11 from IPython.utils.py3compat import string_types
13 12 from IPython.html.utils import url_path_join, url_escape
@@ -23,7 +22,7 b' class MainKernelHandler(IPythonHandler):'
23 22 @json_errors
24 23 def get(self):
25 24 km = self.kernel_manager
26 self.finish(jsonapi.dumps(km.list_kernels()))
25 self.finish(json.dumps(km.list_kernels()))
27 26
28 27 @web.authenticated
29 28 @json_errors
@@ -34,7 +33,7 b' class MainKernelHandler(IPythonHandler):'
34 33 location = url_path_join(self.base_url, 'api', 'kernels', kernel_id)
35 34 self.set_header('Location', url_escape(location))
36 35 self.set_status(201)
37 self.finish(jsonapi.dumps(model))
36 self.finish(json.dumps(model))
38 37
39 38
40 39 class KernelHandler(IPythonHandler):
@@ -47,7 +46,7 b' class KernelHandler(IPythonHandler):'
47 46 km = self.kernel_manager
48 47 km._check_kernel_id(kernel_id)
49 48 model = km.kernel_model(kernel_id)
50 self.finish(jsonapi.dumps(model))
49 self.finish(json.dumps(model))
51 50
52 51 @web.authenticated
53 52 @json_errors
@@ -71,7 +70,7 b' class KernelActionHandler(IPythonHandler):'
71 70 km.restart_kernel(kernel_id)
72 71 model = km.kernel_model(kernel_id)
73 72 self.set_header('Location', '{0}api/kernels/{1}'.format(self.base_url, kernel_id))
74 self.write(jsonapi.dumps(model))
73 self.write(json.dumps(model))
75 74 self.finish()
76 75
77 76
@@ -138,7 +137,7 b' class ZMQChannelHandler(AuthenticatedZMQStreamHandler):'
138 137 self.zmq_stream.on_recv(self._on_zmq_reply)
139 138
140 139 def on_message(self, msg):
141 msg = jsonapi.loads(msg)
140 msg = json.loads(msg)
142 141 self.session.send(self.zmq_stream, msg)
143 142
144 143 def on_close(self):
@@ -177,7 +176,7 b' class IOPubHandler(ZMQChannelHandler):'
177 176 msg = self.session.msg("status",
178 177 {'execution_state': status}
179 178 )
180 self.write_message(jsonapi.dumps(msg, default=date_default))
179 self.write_message(json.dumps(msg, default=date_default))
181 180
182 181 def on_kernel_restarted(self):
183 182 logging.warn("kernel %s restarted", self.kernel_id)
General Comments 0
You need to be logged in to leave comments. Login now