Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding temp refs to msg_type to prevent nested dict gets.

  • Loading branch information...
commit ff292f9cd672167f329e06d013ad3670e22b1a16 1 parent 12aef93
@ellisonbg authored
View
14 IPython/parallel/engine/streamkernel.py
@@ -204,10 +204,11 @@ def dispatch_control(self, msg):
header = msg['header']
msg_id = header['msg_id']
-
- handler = self.control_handlers.get(msg['header']['msg_type'], None)
+ msg_type = header['msg_type']
+
+ handler = self.control_handlers.get(msg_type, None)
if handler is None:
- self.log.error("UNKNOWN CONTROL MESSAGE TYPE: %r"%msg['header']['msg_type'])
+ self.log.error("UNKNOWN CONTROL MESSAGE TYPE: %r"%msg_type)
else:
handler(self.control_stream, idents, msg)
@@ -383,17 +384,18 @@ def dispatch_queue(self, stream, msg):
header = msg['header']
msg_id = header['msg_id']
+ msg['header']['msg_type']
if self.check_aborted(msg_id):
self.aborted.remove(msg_id)
# is it safe to assume a msg_id will not be resubmitted?
- reply_type = msg['header']['msg_type'].split('_')[0] + '_reply'
+ reply_type = msg_type.split('_')[0] + '_reply'
status = {'status' : 'aborted'}
reply_msg = self.session.send(stream, reply_type, subheader=status,
content=status, parent=msg, ident=idents)
return
- handler = self.shell_handlers.get(msg['header']['msg_type'], None)
+ handler = self.shell_handlers.get(msg_type, None)
if handler is None:
- self.log.error("UNKNOWN MESSAGE TYPE: %r"%msg['header']['msg_type'])
+ self.log.error("UNKNOWN MESSAGE TYPE: %r"%msg_type)
else:
handler(stream, idents, msg)
View
5 IPython/parallel/tests/test_db.py
@@ -56,8 +56,9 @@ def load_records(self, n=1):
msg = self.session.msg('apply_request', content=dict(a=5))
msg['buffers'] = []
rec = init_record(msg)
- msg_ids.append(msg['header']['msg_id'])
- self.db.add_record(msg['header']['msg_id'], rec)
+ msg_id = msg['header']['msg_id']
+ msg_ids.append(msg_id)
+ self.db.add_record(msg_id, rec)
return msg_ids
def test_add_record(self):
View
5 IPython/zmq/ipkernel.py
@@ -122,6 +122,7 @@ def do_one_iteration(self):
"""Do one iteration of the kernel's evaluation loop.
"""
ident,msg = self.session.recv(self.shell_socket, zmq.NOBLOCK)
+ msg_type = msg['header']['msg_type']
if msg is None:
return
@@ -133,11 +134,11 @@ def do_one_iteration(self):
# Print some info about this message and leave a '--->' marker, so it's
# easier to trace visually the message chain when debugging. Each
# handler prints its message at the end.
- self.log.debug('\n*** MESSAGE TYPE:'+str(msg['header']['msg_type'])+'***')
+ self.log.debug('\n*** MESSAGE TYPE:'+str(msg_type)+'***')
self.log.debug(' Content: '+str(msg['content'])+'\n --->\n ')
# Find and call actual handler for message
- handler = self.handlers.get(msg['header']['msg_type'], None)
+ handler = self.handlers.get(msg_type, None)
if handler is None:
self.log.error("UNKNOWN MESSAGE TYPE:" +str(msg))
else:
Please sign in to comment.
Something went wrong with that request. Please try again.