Show More
@@ -192,6 +192,7 b' class KernelApp(BaseIPythonApplication):' | |||
|
192 | 192 | shell_socket=self.shell_socket, |
|
193 | 193 | iopub_socket=self.iopub_socket, |
|
194 | 194 | stdin_socket=self.stdin_socket, |
|
195 | log=self.log | |
|
195 | 196 | ) |
|
196 | 197 | self.kernel.record_ports(self.ports) |
|
197 | 198 |
@@ -60,6 +60,7 b' class Kernel(HasTraits):' | |||
|
60 | 60 | shell_socket = Instance('zmq.Socket') |
|
61 | 61 | iopub_socket = Instance('zmq.Socket') |
|
62 | 62 | stdin_socket = Instance('zmq.Socket') |
|
63 | log = Instance('logging.Logger') | |
|
63 | 64 | |
|
64 | 65 | def __init__(self, **kwargs): |
|
65 | 66 | super(Kernel, self).__init__(**kwargs) |
@@ -82,11 +83,10 b' class Kernel(HasTraits):' | |||
|
82 | 83 | ident,msg = self.session.recv(self.shell_socket,0) |
|
83 | 84 | assert ident is not None, "Missing message part." |
|
84 | 85 | omsg = Message(msg) |
|
85 | print>>sys.__stdout__ | |
|
86 | print>>sys.__stdout__, omsg | |
|
86 | self.log.debug(str(omsg)) | |
|
87 | 87 | handler = self.handlers.get(omsg.msg_type, None) |
|
88 | 88 | if handler is None: |
|
89 |
|
|
|
89 | self.log.error("UNKNOWN MESSAGE TYPE: %s"%omsg) | |
|
90 | 90 | else: |
|
91 | 91 | handler(ident, omsg) |
|
92 | 92 | |
@@ -106,8 +106,7 b' class Kernel(HasTraits):' | |||
|
106 | 106 | try: |
|
107 | 107 | code = parent[u'content'][u'code'] |
|
108 | 108 | except: |
|
109 | print>>sys.__stderr__, "Got bad msg: " | |
|
110 | print>>sys.__stderr__, Message(parent) | |
|
109 | self.log.error("Got bad msg: %s"%Message(parent)) | |
|
111 | 110 | return |
|
112 | 111 | pyin_msg = self.session.send(self.iopub_socket, u'pyin',{u'code':code}, parent=parent) |
|
113 | 112 | |
@@ -150,7 +149,7 b' class Kernel(HasTraits):' | |||
|
150 | 149 | |
|
151 | 150 | # Send the reply. |
|
152 | 151 | reply_msg = self.session.send(self.shell_socket, u'execute_reply', reply_content, parent, ident=ident) |
|
153 |
|
|
|
152 | self.log.debug(Message(reply_msg)) | |
|
154 | 153 | if reply_msg['content']['status'] == u'error': |
|
155 | 154 | self._abort_queue() |
|
156 | 155 | |
@@ -159,14 +158,14 b' class Kernel(HasTraits):' | |||
|
159 | 158 | 'status' : 'ok'} |
|
160 | 159 | completion_msg = self.session.send(self.shell_socket, 'complete_reply', |
|
161 | 160 | matches, parent, ident) |
|
162 |
|
|
|
161 | self.log.debug(completion_msg) | |
|
163 | 162 | |
|
164 | 163 | def object_info_request(self, ident, parent): |
|
165 | 164 | context = parent['content']['oname'].split('.') |
|
166 | 165 | object_info = self._object_info(context) |
|
167 | 166 | msg = self.session.send(self.shell_socket, 'object_info_reply', |
|
168 | 167 | object_info, parent, ident) |
|
169 | print >> sys.__stdout__, msg | |
|
168 | self.log.debug(msg) | |
|
170 | 169 | |
|
171 | 170 | def shutdown_request(self, ident, parent): |
|
172 | 171 | content = dict(parent['content']) |
@@ -174,7 +173,7 b' class Kernel(HasTraits):' | |||
|
174 | 173 | content, parent, ident) |
|
175 | 174 | msg = self.session.send(self.iopub_socket, 'shutdown_reply', |
|
176 | 175 | content, parent, ident) |
|
177 | print >> sys.__stdout__, msg | |
|
176 | self.log.debug(msg) | |
|
178 | 177 | time.sleep(0.1) |
|
179 | 178 | sys.exit(0) |
|
180 | 179 | |
@@ -184,17 +183,17 b' class Kernel(HasTraits):' | |||
|
184 | 183 | |
|
185 | 184 | def _abort_queue(self): |
|
186 | 185 | while True: |
|
187 |
ident,msg = self.session.recv(self. |
|
|
186 | ident,msg = self.session.recv(self.shell_socket, zmq.NOBLOCK) | |
|
188 | 187 | if msg is None: |
|
188 | # msg=None on EAGAIN | |
|
189 | 189 | break |
|
190 | 190 | else: |
|
191 |
assert ident is not None, " |
|
|
192 | print>>sys.__stdout__, "Aborting:" | |
|
193 | print>>sys.__stdout__, Message(msg) | |
|
191 | assert ident is not None, "Missing message part." | |
|
192 | self.log.debug("Aborting: %s"%Message(msg)) | |
|
194 | 193 | msg_type = msg['msg_type'] |
|
195 | 194 | reply_type = msg_type.split('_')[0] + '_reply' |
|
196 | 195 | reply_msg = self.session.send(self.shell_socket, reply_type, {'status':'aborted'}, msg, ident=ident) |
|
197 |
|
|
|
196 | self.log.debug(Message(reply_msg)) | |
|
198 | 197 | # We need to wait a bit for requests to come in. This can probably |
|
199 | 198 | # be set shorter for true asynchronous clients. |
|
200 | 199 | time.sleep(0.1) |
@@ -213,8 +212,7 b' class Kernel(HasTraits):' | |||
|
213 | 212 | try: |
|
214 | 213 | value = reply['content']['value'] |
|
215 | 214 | except: |
|
216 |
|
|
|
217 | print>>sys.__stderr__, Message(parent) | |
|
215 | self.log.error("Got bad raw_input reply: %s"%Message(parent)) | |
|
218 | 216 | value = '' |
|
219 | 217 | return value |
|
220 | 218 |
General Comments 0
You need to be logged in to leave comments.
Login now