Show More
@@ -1378,9 +1378,11 b' class Client(HasTraits):' | |||||
1378 | block = self.block if block is None else block |
|
1378 | block = self.block if block is None else block | |
1379 | if indices_or_msg_ids is None: |
|
1379 | if indices_or_msg_ids is None: | |
1380 | indices_or_msg_ids = -1 |
|
1380 | indices_or_msg_ids = -1 | |
1381 |
|
1381 | |||
|
1382 | single_result = False | |||
1382 | if not isinstance(indices_or_msg_ids, (list,tuple)): |
|
1383 | if not isinstance(indices_or_msg_ids, (list,tuple)): | |
1383 | indices_or_msg_ids = [indices_or_msg_ids] |
|
1384 | indices_or_msg_ids = [indices_or_msg_ids] | |
|
1385 | single_result = True | |||
1384 |
|
1386 | |||
1385 | theids = [] |
|
1387 | theids = [] | |
1386 | for id in indices_or_msg_ids: |
|
1388 | for id in indices_or_msg_ids: | |
@@ -1392,6 +1394,11 b' class Client(HasTraits):' | |||||
1392 |
|
1394 | |||
1393 | local_ids = filter(lambda msg_id: msg_id in self.outstanding or msg_id in self.results, theids) |
|
1395 | local_ids = filter(lambda msg_id: msg_id in self.outstanding or msg_id in self.results, theids) | |
1394 | remote_ids = filter(lambda msg_id: msg_id not in local_ids, theids) |
|
1396 | remote_ids = filter(lambda msg_id: msg_id not in local_ids, theids) | |
|
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] | |||
1395 |
|
1402 | |||
1396 | if remote_ids: |
|
1403 | if remote_ids: | |
1397 | ar = AsyncHubResult(self, msg_ids=theids) |
|
1404 | ar = AsyncHubResult(self, msg_ids=theids) |
@@ -152,10 +152,10 b' class TestClient(ClusterTestCase):' | |||||
152 | ar = c[t].apply_async(wait, 1) |
|
152 | ar = c[t].apply_async(wait, 1) | |
153 | # give the monitor time to notice the message |
|
153 | # give the monitor time to notice the message | |
154 | time.sleep(.25) |
|
154 | time.sleep(.25) | |
155 | ahr = self.client.get_result(ar.msg_ids) |
|
155 | ahr = self.client.get_result(ar.msg_ids[0]) | |
156 | self.assertTrue(isinstance(ahr, AsyncHubResult)) |
|
156 | self.assertTrue(isinstance(ahr, AsyncHubResult)) | |
157 | self.assertEqual(ahr.get(), ar.get()) |
|
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 | self.assertFalse(isinstance(ar2, AsyncHubResult)) |
|
159 | self.assertFalse(isinstance(ar2, AsyncHubResult)) | |
160 | c.close() |
|
160 | c.close() | |
161 |
|
161 | |||
@@ -171,10 +171,11 b' class TestClient(ClusterTestCase):' | |||||
171 | ar = c[t].execute("import time; time.sleep(1)", silent=False) |
|
171 | ar = c[t].execute("import time; time.sleep(1)", silent=False) | |
172 | # give the monitor time to notice the message |
|
172 | # give the monitor time to notice the message | |
173 | time.sleep(.25) |
|
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 | self.assertTrue(isinstance(ahr, AsyncHubResult)) |
|
176 | self.assertTrue(isinstance(ahr, AsyncHubResult)) | |
176 | self.assertEqual(ahr.get().pyout, ar.get().pyout) |
|
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 | self.assertFalse(isinstance(ar2, AsyncHubResult)) |
|
179 | self.assertFalse(isinstance(ar2, AsyncHubResult)) | |
179 | c.close() |
|
180 | c.close() | |
180 |
|
181 |
@@ -156,10 +156,10 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
156 | ar = v.apply_async(wait, 1) |
|
156 | ar = v.apply_async(wait, 1) | |
157 | # give the monitor time to notice the message |
|
157 | # give the monitor time to notice the message | |
158 | time.sleep(.25) |
|
158 | time.sleep(.25) | |
159 | ahr = v2.get_result(ar.msg_ids) |
|
159 | ahr = v2.get_result(ar.msg_ids[0]) | |
160 | self.assertTrue(isinstance(ahr, AsyncHubResult)) |
|
160 | self.assertTrue(isinstance(ahr, AsyncHubResult)) | |
161 | self.assertEqual(ahr.get(), ar.get()) |
|
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 | self.assertFalse(isinstance(ar2, AsyncHubResult)) |
|
163 | self.assertFalse(isinstance(ar2, AsyncHubResult)) | |
164 | c.spin() |
|
164 | c.spin() | |
165 | c.close() |
|
165 | c.close() |
General Comments 0
You need to be logged in to leave comments.
Login now