diff --git a/IPython/parallel/client/client.py b/IPython/parallel/client/client.py index bcd912b..455f764 100644 --- a/IPython/parallel/client/client.py +++ b/IPython/parallel/client/client.py @@ -1378,9 +1378,11 @@ class Client(HasTraits): block = self.block if block is None else block if indices_or_msg_ids is None: indices_or_msg_ids = -1 - + + single_result = False if not isinstance(indices_or_msg_ids, (list,tuple)): indices_or_msg_ids = [indices_or_msg_ids] + single_result = True theids = [] for id in indices_or_msg_ids: @@ -1392,6 +1394,11 @@ class Client(HasTraits): local_ids = filter(lambda msg_id: msg_id in self.outstanding or msg_id in self.results, theids) remote_ids = filter(lambda msg_id: msg_id not in local_ids, theids) + + # given single msg_id initially, get_result shot get the result itself, + # not a length-one list + if single_result: + theids = theids[0] if remote_ids: ar = AsyncHubResult(self, msg_ids=theids) diff --git a/IPython/parallel/tests/test_client.py b/IPython/parallel/tests/test_client.py index cd8456b..2464755 100644 --- a/IPython/parallel/tests/test_client.py +++ b/IPython/parallel/tests/test_client.py @@ -152,10 +152,10 @@ class TestClient(ClusterTestCase): ar = c[t].apply_async(wait, 1) # give the monitor time to notice the message time.sleep(.25) - ahr = self.client.get_result(ar.msg_ids) + ahr = self.client.get_result(ar.msg_ids[0]) self.assertTrue(isinstance(ahr, AsyncHubResult)) self.assertEqual(ahr.get(), ar.get()) - ar2 = self.client.get_result(ar.msg_ids) + ar2 = self.client.get_result(ar.msg_ids[0]) self.assertFalse(isinstance(ar2, AsyncHubResult)) c.close() @@ -171,10 +171,11 @@ class TestClient(ClusterTestCase): ar = c[t].execute("import time; time.sleep(1)", silent=False) # give the monitor time to notice the message time.sleep(.25) - ahr = self.client.get_result(ar.msg_ids) + ahr = self.client.get_result(ar.msg_ids[0]) + print ar.get(), ahr.get(), ar._single_result, ahr._single_result self.assertTrue(isinstance(ahr, AsyncHubResult)) self.assertEqual(ahr.get().pyout, ar.get().pyout) - ar2 = self.client.get_result(ar.msg_ids) + ar2 = self.client.get_result(ar.msg_ids[0]) self.assertFalse(isinstance(ar2, AsyncHubResult)) c.close() diff --git a/IPython/parallel/tests/test_view.py b/IPython/parallel/tests/test_view.py index bdac799..7a3540e 100644 --- a/IPython/parallel/tests/test_view.py +++ b/IPython/parallel/tests/test_view.py @@ -156,10 +156,10 @@ class TestView(ClusterTestCase, ParametricTestCase): ar = v.apply_async(wait, 1) # give the monitor time to notice the message time.sleep(.25) - ahr = v2.get_result(ar.msg_ids) + ahr = v2.get_result(ar.msg_ids[0]) self.assertTrue(isinstance(ahr, AsyncHubResult)) self.assertEqual(ahr.get(), ar.get()) - ar2 = v2.get_result(ar.msg_ids) + ar2 = v2.get_result(ar.msg_ids[0]) self.assertFalse(isinstance(ar2, AsyncHubResult)) c.spin() c.close()