##// END OF EJS Templates
fix AsyncResult.abort...
MinRK -
Show More
@@ -195,7 +195,7 b' class AsyncResult(object):'
195 def abort(self):
195 def abort(self):
196 """abort my tasks."""
196 """abort my tasks."""
197 assert not self.ready(), "Can't abort, I am already done!"
197 assert not self.ready(), "Can't abort, I am already done!"
198 return self.client.abort(self.msg_ids, targets=self._targets, block=True)
198 return self._client.abort(self.msg_ids, targets=self._targets, block=True)
199
199
200 @property
200 @property
201 def sent(self):
201 def sent(self):
@@ -19,6 +19,7 b' Authors:'
19
19
20 from IPython.parallel.error import TimeoutError
20 from IPython.parallel.error import TimeoutError
21
21
22 from IPython.parallel import error
22 from IPython.parallel.tests import add_engines
23 from IPython.parallel.tests import add_engines
23 from .clienttest import ClusterTestCase
24 from .clienttest import ClusterTestCase
24
25
@@ -32,7 +33,8 b' def wait(n):'
32
33
33 class AsyncResultTest(ClusterTestCase):
34 class AsyncResultTest(ClusterTestCase):
34
35
35 def test_single_result(self):
36 def test_single_result_view(self):
37 """various one-target views get the right value for single_result"""
36 eid = self.client.ids[-1]
38 eid = self.client.ids[-1]
37 ar = self.client[eid].apply_async(lambda : 42)
39 ar = self.client[eid].apply_async(lambda : 42)
38 self.assertEquals(ar.get(), 42)
40 self.assertEquals(ar.get(), 42)
@@ -111,5 +113,13 b' class AsyncResultTest(ClusterTestCase):'
111 self.assertTrue(isinstance(ar['engine_id'], int))
113 self.assertTrue(isinstance(ar['engine_id'], int))
112 self.assertTrue(isinstance(ar.engine_id, int))
114 self.assertTrue(isinstance(ar.engine_id, int))
113 self.assertEquals(ar.engine_id, ar['engine_id'])
115 self.assertEquals(ar.engine_id, ar['engine_id'])
116
117 def test_abort(self):
118 e = self.client[-1]
119 ar = e.execute('import time; time.sleep(1)', block=False)
120 ar2 = e.apply_async(lambda : 2)
121 ar2.abort()
122 self.assertRaises(error.TaskAborted, ar2.get)
123 ar.get()
114
124
115
125
General Comments 0
You need to be logged in to leave comments. Login now