##// END OF EJS Templates
fix & test HubResults from execute requests
MinRK -
Show More
@@ -1543,11 +1543,15 b' class Client(HasTraits):'
1543 if rec.get('received'):
1543 if rec.get('received'):
1544 md['received'] = rec['received']
1544 md['received'] = rec['received']
1545 md.update(iodict)
1545 md.update(iodict)
1546
1546
1547 if rcontent['status'] == 'ok':
1547 if rcontent['status'] == 'ok':
1548 res,buffers = util.unserialize_object(buffers)
1548 if header['msg_type'] == 'apply_reply':
1549 res,buffers = util.unserialize_object(buffers)
1550 elif header['msg_type'] == 'execute_reply':
1551 res = ExecuteReply(msg_id, rcontent, md)
1552 else:
1553 raise KeyError("unhandled msg type: %r" % header[msg_type])
1549 else:
1554 else:
1550 print rcontent
1551 res = self._unwrap_exception(rcontent)
1555 res = self._unwrap_exception(rcontent)
1552 failures.append(res)
1556 failures.append(res)
1553
1557
@@ -1555,7 +1559,7 b' class Client(HasTraits):'
1555 content[msg_id] = res
1559 content[msg_id] = res
1556
1560
1557 if len(theids) == 1 and failures:
1561 if len(theids) == 1 and failures:
1558 raise failures[0]
1562 raise failures[0]
1559
1563
1560 error.collect_exceptions(failures, "result_status")
1564 error.collect_exceptions(failures, "result_status")
1561 return content
1565 return content
@@ -824,8 +824,15 b' class Hub(SessionFactory):'
824 d['pyerr'] = content
824 d['pyerr'] = content
825 elif msg_type == 'pyin':
825 elif msg_type == 'pyin':
826 d['pyin'] = content['code']
826 d['pyin'] = content['code']
827 elif msg_type in ('display_data', 'pyout'):
828 d[msg_type] = content
829 elif msg_type == 'status':
830 pass
827 else:
831 else:
828 d[msg_type] = content.get('data', '')
832 self.log.warn("unhandled iopub msg_type: %r", msg_type)
833
834 if not d:
835 return
829
836
830 try:
837 try:
831 self.db.update_record(msg_id, d)
838 self.db.update_record(msg_id, d)
@@ -159,6 +159,25 b' class TestClient(ClusterTestCase):'
159 self.assertFalse(isinstance(ar2, AsyncHubResult))
159 self.assertFalse(isinstance(ar2, AsyncHubResult))
160 c.close()
160 c.close()
161
161
162 def test_get_execute_result(self):
163 """test getting execute results from the Hub."""
164 c = clientmod.Client(profile='iptest')
165 t = c.ids[-1]
166 cell = '\n'.join([
167 'import time',
168 'time.sleep(0.25)',
169 '5'
170 ])
171 ar = c[t].execute("import time; time.sleep(1)", silent=False)
172 # give the monitor time to notice the message
173 time.sleep(.25)
174 ahr = self.client.get_result(ar.msg_ids)
175 self.assertTrue(isinstance(ahr, AsyncHubResult))
176 self.assertEquals(ahr.get().pyout, ar.get().pyout)
177 ar2 = self.client.get_result(ar.msg_ids)
178 self.assertFalse(isinstance(ar2, AsyncHubResult))
179 c.close()
180
162 def test_ids_list(self):
181 def test_ids_list(self):
163 """test client.ids"""
182 """test client.ids"""
164 ids = self.client.ids
183 ids = self.client.ids
General Comments 0
You need to be logged in to leave comments. Login now