##// END OF EJS Templates
update client.get_result to match AsyncResult behavior
MinRK -
Show More
@@ -1379,8 +1379,10 b' class Client(HasTraits):'
1379 1379 if indices_or_msg_ids is None:
1380 1380 indices_or_msg_ids = -1
1381 1381
1382 single_result = False
1382 1383 if not isinstance(indices_or_msg_ids, (list,tuple)):
1383 1384 indices_or_msg_ids = [indices_or_msg_ids]
1385 single_result = True
1384 1386
1385 1387 theids = []
1386 1388 for id in indices_or_msg_ids:
@@ -1393,6 +1395,11 b' class Client(HasTraits):'
1393 1395 local_ids = filter(lambda msg_id: msg_id in self.outstanding or msg_id in self.results, theids)
1394 1396 remote_ids = filter(lambda msg_id: msg_id not in local_ids, theids)
1395 1397
1398 # given single msg_id initially, get_result shot get the result itself,
1399 # not a length-one list
1400 if single_result:
1401 theids = theids[0]
1402
1396 1403 if remote_ids:
1397 1404 ar = AsyncHubResult(self, msg_ids=theids)
1398 1405 else:
@@ -152,10 +152,10 b' class TestClient(ClusterTestCase):'
152 152 ar = c[t].apply_async(wait, 1)
153 153 # give the monitor time to notice the message
154 154 time.sleep(.25)
155 ahr = self.client.get_result(ar.msg_ids)
155 ahr = self.client.get_result(ar.msg_ids[0])
156 156 self.assertTrue(isinstance(ahr, AsyncHubResult))
157 157 self.assertEqual(ahr.get(), ar.get())
158 ar2 = self.client.get_result(ar.msg_ids)
158 ar2 = self.client.get_result(ar.msg_ids[0])
159 159 self.assertFalse(isinstance(ar2, AsyncHubResult))
160 160 c.close()
161 161
@@ -171,10 +171,11 b' class TestClient(ClusterTestCase):'
171 171 ar = c[t].execute("import time; time.sleep(1)", silent=False)
172 172 # give the monitor time to notice the message
173 173 time.sleep(.25)
174 ahr = self.client.get_result(ar.msg_ids)
174 ahr = self.client.get_result(ar.msg_ids[0])
175 print ar.get(), ahr.get(), ar._single_result, ahr._single_result
175 176 self.assertTrue(isinstance(ahr, AsyncHubResult))
176 177 self.assertEqual(ahr.get().pyout, ar.get().pyout)
177 ar2 = self.client.get_result(ar.msg_ids)
178 ar2 = self.client.get_result(ar.msg_ids[0])
178 179 self.assertFalse(isinstance(ar2, AsyncHubResult))
179 180 c.close()
180 181
@@ -156,10 +156,10 b' class TestView(ClusterTestCase, ParametricTestCase):'
156 156 ar = v.apply_async(wait, 1)
157 157 # give the monitor time to notice the message
158 158 time.sleep(.25)
159 ahr = v2.get_result(ar.msg_ids)
159 ahr = v2.get_result(ar.msg_ids[0])
160 160 self.assertTrue(isinstance(ahr, AsyncHubResult))
161 161 self.assertEqual(ahr.get(), ar.get())
162 ar2 = v2.get_result(ar.msg_ids)
162 ar2 = v2.get_result(ar.msg_ids[0])
163 163 self.assertFalse(isinstance(ar2, AsyncHubResult))
164 164 c.spin()
165 165 c.close()
General Comments 0
You need to be logged in to leave comments. Login now