Show More
@@ -24,7 +24,7 b' from kernelmanager import KernelManager' | |||||
24 | options.define("port", default=8888, help="run on the given port", type=int) |
|
24 | options.define("port", default=8888, help="run on the given port", type=int) | |
25 |
|
25 | |||
26 | _kernel_id_regex = r"(?P<kernel_id>\w+-\w+-\w+-\w+-\w+)" |
|
26 | _kernel_id_regex = r"(?P<kernel_id>\w+-\w+-\w+-\w+-\w+)" | |
27 |
|
27 | _kernel_action_regex = r"(?P<action>restart|interrupt)" | ||
28 |
|
28 | |||
29 | class MainHandler(web.RequestHandler): |
|
29 | class MainHandler(web.RequestHandler): | |
30 | def get(self): |
|
30 | def get(self): | |
@@ -43,14 +43,13 b' class KernelHandler(web.RequestHandler):' | |||||
43 |
|
43 | |||
44 | class KernelActionHandler(web.RequestHandler): |
|
44 | class KernelActionHandler(web.RequestHandler): | |
45 |
|
45 | |||
46 |
def |
|
46 | def post(self, kernel_id, action): | |
47 | # TODO: figure out a better way of handling RPC style calls. |
|
47 | # TODO: figure out a better way of handling RPC style calls. | |
48 | if self.request.arguments.has_key('interrupt'): |
|
48 | if action == 'interrupt': | |
49 | self.application.interrupt_kernel(kernel_id) |
|
49 | self.application.interrupt_kernel(kernel_id) | |
50 | if self.request.arguments.has_key('restart'): |
|
50 | if action == 'restart': | |
51 | new_kernel_id = self.application.restart_kernel(kernel_id) |
|
51 | new_kernel_id = self.application.restart_kernel(kernel_id) | |
52 | self.write(json.dumps(new_kernel_id)) |
|
52 | self.write(json.dumps(new_kernel_id)) | |
53 | logging.info(repr(self.request.arguments)) |
|
|||
54 |
|
53 | |||
55 |
|
54 | |||
56 | class ZMQStreamRouter(object): |
|
55 | class ZMQStreamRouter(object): | |
@@ -176,7 +175,7 b' class NotebookApplication(web.Application):' | |||||
176 | handlers = [ |
|
175 | handlers = [ | |
177 | (r"/", MainHandler), |
|
176 | (r"/", MainHandler), | |
178 | (r"/kernels", KernelHandler), |
|
177 | (r"/kernels", KernelHandler), | |
179 |
(r"/kernels/%s/ |
|
178 | (r"/kernels/%s/%s" % (_kernel_id_regex, _kernel_action_regex), KernelActionHandler), | |
180 | (r"/kernels/%s/iopub" % _kernel_id_regex, ZMQStreamHandler, dict(stream_name='iopub')), |
|
179 | (r"/kernels/%s/iopub" % _kernel_id_regex, ZMQStreamHandler, dict(stream_name='iopub')), | |
181 | (r"/kernels/%s/shell" % _kernel_id_regex, ZMQStreamHandler, dict(stream_name='shell')), |
|
180 | (r"/kernels/%s/shell" % _kernel_id_regex, ZMQStreamHandler, dict(stream_name='shell')), | |
182 | (r"/notebooks", NotebookRootHandler), |
|
181 | (r"/notebooks", NotebookRootHandler), |
@@ -764,18 +764,18 b' Kernel.prototype.execute = function (code) {' | |||||
764 |
|
764 | |||
765 |
|
765 | |||
766 | Kernel.prototype.interrupt = function () { |
|
766 | Kernel.prototype.interrupt = function () { | |
767 |
$. |
|
767 | $.post(this.kernel_url + "/interrupt"); | |
768 | }; |
|
768 | }; | |
769 |
|
769 | |||
770 |
|
770 | |||
771 | Kernel.prototype.restart = function () { |
|
771 | Kernel.prototype.restart = function () { | |
772 |
url = this.kernel_url + "/ |
|
772 | url = this.kernel_url + "/restart" | |
773 | var that = this; |
|
773 | var that = this; | |
774 |
$. |
|
774 | $.post(url, function (kernel_id) { | |
775 | console.log("Kernel restarted: " + kernel_id); |
|
775 | console.log("Kernel restarted: " + kernel_id); | |
776 | that.kernel_id = kernel_id; |
|
776 | that.kernel_id = kernel_id; | |
777 | that.kernel_url = that.base_url + "/" + that.kernel_id; |
|
777 | that.kernel_url = that.base_url + "/" + that.kernel_id; | |
778 | }); |
|
778 | }, 'json'); | |
779 | }; |
|
779 | }; | |
780 |
|
780 | |||
781 |
|
781 |
General Comments 0
You need to be logged in to leave comments.
Login now