Skip to content

Commit

Permalink
Merge pull request ipython#1565 from minrk/abort
Browse files Browse the repository at this point in the history
Fix bug when calling AsyncResult.abort().
  • Loading branch information
fperez committed Apr 10, 2012
2 parents 3b34fa9 + 5ad214b commit 9dae5bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion IPython/parallel/client/asyncresult.py
Expand Up @@ -195,7 +195,7 @@ def __dict__(self):
def abort(self):
"""abort my tasks."""
assert not self.ready(), "Can't abort, I am already done!"
return self.client.abort(self.msg_ids, targets=self._targets, block=True)
return self._client.abort(self.msg_ids, targets=self._targets, block=True)

@property
def sent(self):
Expand Down
12 changes: 11 additions & 1 deletion IPython/parallel/tests/test_asyncresult.py
Expand Up @@ -19,6 +19,7 @@

from IPython.parallel.error import TimeoutError

from IPython.parallel import error
from IPython.parallel.tests import add_engines
from .clienttest import ClusterTestCase

Expand All @@ -32,7 +33,8 @@ def wait(n):

class AsyncResultTest(ClusterTestCase):

def test_single_result(self):
def test_single_result_view(self):
"""various one-target views get the right value for single_result"""
eid = self.client.ids[-1]
ar = self.client[eid].apply_async(lambda : 42)
self.assertEquals(ar.get(), 42)
Expand Down Expand Up @@ -111,5 +113,13 @@ def test_single_result(self):
self.assertTrue(isinstance(ar['engine_id'], int))
self.assertTrue(isinstance(ar.engine_id, int))
self.assertEquals(ar.engine_id, ar['engine_id'])

def test_abort(self):
e = self.client[-1]
ar = e.execute('import time; time.sleep(1)', block=False)
ar2 = e.apply_async(lambda : 2)
ar2.abort()
self.assertRaises(error.TaskAborted, ar2.get)
ar.get()


0 comments on commit 9dae5bf

Please sign in to comment.