##// END OF EJS Templates
Adding temp refs to msg_type to prevent nested dict gets.
Brian E. Granger -
Show More
@@ -204,10 +204,11 b' class Kernel(SessionFactory):'
204
204
205 header = msg['header']
205 header = msg['header']
206 msg_id = header['msg_id']
206 msg_id = header['msg_id']
207
207 msg_type = header['msg_type']
208 handler = self.control_handlers.get(msg['header']['msg_type'], None)
208
209 handler = self.control_handlers.get(msg_type, None)
209 if handler is None:
210 if handler is None:
210 self.log.error("UNKNOWN CONTROL MESSAGE TYPE: %r"%msg['header']['msg_type'])
211 self.log.error("UNKNOWN CONTROL MESSAGE TYPE: %r"%msg_type)
211 else:
212 else:
212 handler(self.control_stream, idents, msg)
213 handler(self.control_stream, idents, msg)
213
214
@@ -383,17 +384,18 b' class Kernel(SessionFactory):'
383
384
384 header = msg['header']
385 header = msg['header']
385 msg_id = header['msg_id']
386 msg_id = header['msg_id']
387 msg['header']['msg_type']
386 if self.check_aborted(msg_id):
388 if self.check_aborted(msg_id):
387 self.aborted.remove(msg_id)
389 self.aborted.remove(msg_id)
388 # is it safe to assume a msg_id will not be resubmitted?
390 # is it safe to assume a msg_id will not be resubmitted?
389 reply_type = msg['header']['msg_type'].split('_')[0] + '_reply'
391 reply_type = msg_type.split('_')[0] + '_reply'
390 status = {'status' : 'aborted'}
392 status = {'status' : 'aborted'}
391 reply_msg = self.session.send(stream, reply_type, subheader=status,
393 reply_msg = self.session.send(stream, reply_type, subheader=status,
392 content=status, parent=msg, ident=idents)
394 content=status, parent=msg, ident=idents)
393 return
395 return
394 handler = self.shell_handlers.get(msg['header']['msg_type'], None)
396 handler = self.shell_handlers.get(msg_type, None)
395 if handler is None:
397 if handler is None:
396 self.log.error("UNKNOWN MESSAGE TYPE: %r"%msg['header']['msg_type'])
398 self.log.error("UNKNOWN MESSAGE TYPE: %r"%msg_type)
397 else:
399 else:
398 handler(stream, idents, msg)
400 handler(stream, idents, msg)
399
401
@@ -56,8 +56,9 b' class TestDictBackend(TestCase):'
56 msg = self.session.msg('apply_request', content=dict(a=5))
56 msg = self.session.msg('apply_request', content=dict(a=5))
57 msg['buffers'] = []
57 msg['buffers'] = []
58 rec = init_record(msg)
58 rec = init_record(msg)
59 msg_ids.append(msg['header']['msg_id'])
59 msg_id = msg['header']['msg_id']
60 self.db.add_record(msg['header']['msg_id'], rec)
60 msg_ids.append(msg_id)
61 self.db.add_record(msg_id, rec)
61 return msg_ids
62 return msg_ids
62
63
63 def test_add_record(self):
64 def test_add_record(self):
@@ -122,6 +122,7 b' class Kernel(Configurable):'
122 """Do one iteration of the kernel's evaluation loop.
122 """Do one iteration of the kernel's evaluation loop.
123 """
123 """
124 ident,msg = self.session.recv(self.shell_socket, zmq.NOBLOCK)
124 ident,msg = self.session.recv(self.shell_socket, zmq.NOBLOCK)
125 msg_type = msg['header']['msg_type']
125 if msg is None:
126 if msg is None:
126 return
127 return
127
128
@@ -133,11 +134,11 b' class Kernel(Configurable):'
133 # Print some info about this message and leave a '--->' marker, so it's
134 # Print some info about this message and leave a '--->' marker, so it's
134 # easier to trace visually the message chain when debugging. Each
135 # easier to trace visually the message chain when debugging. Each
135 # handler prints its message at the end.
136 # handler prints its message at the end.
136 self.log.debug('\n*** MESSAGE TYPE:'+str(msg['header']['msg_type'])+'***')
137 self.log.debug('\n*** MESSAGE TYPE:'+str(msg_type)+'***')
137 self.log.debug(' Content: '+str(msg['content'])+'\n --->\n ')
138 self.log.debug(' Content: '+str(msg['content'])+'\n --->\n ')
138
139
139 # Find and call actual handler for message
140 # Find and call actual handler for message
140 handler = self.handlers.get(msg['header']['msg_type'], None)
141 handler = self.handlers.get(msg_type, None)
141 if handler is None:
142 if handler is None:
142 self.log.error("UNKNOWN MESSAGE TYPE:" +str(msg))
143 self.log.error("UNKNOWN MESSAGE TYPE:" +str(msg))
143 else:
144 else:
General Comments 0
You need to be logged in to leave comments. Login now