Show More
@@ -29,6 +29,17 b' def segfault():' | |||
|
29 | 29 | import ctypes |
|
30 | 30 | ctypes.memset(-1,0,1) |
|
31 | 31 | |
|
32 | def crash(): | |
|
33 | """from stdlib crashers in the test suite""" | |
|
34 | import types | |
|
35 | if sys.platform.startswith('win'): | |
|
36 | import ctypes | |
|
37 | ctypes.windll.kernel32.SetErrorMode(0x0002); | |
|
38 | ||
|
39 | co = types.CodeType(0, 0, 0, 0, b'\x04\x71\x00\x00', | |
|
40 | (), (), (), '', '', 1, b'') | |
|
41 | exec(co) | |
|
42 | ||
|
32 | 43 | def wait(n): |
|
33 | 44 | """sleep for a time""" |
|
34 | 45 | import time |
@@ -86,7 +97,7 b' class ClusterTestCase(BaseZMQTestCase):' | |||
|
86 | 97 | except error.CompositeError as e: |
|
87 | 98 | e.raise_exception() |
|
88 | 99 | except error.RemoteError as e: |
|
89 |
self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(e.ename |
|
|
100 | self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename)) | |
|
90 | 101 | else: |
|
91 | 102 | self.fail("should have raised a RemoteError") |
|
92 | 103 |
@@ -25,33 +25,37 b' from IPython.parallel.util import interactive' | |||
|
25 | 25 | |
|
26 | 26 | from IPython.parallel.tests import add_engines |
|
27 | 27 | |
|
28 |
from .clienttest import ClusterTestCase, |
|
|
28 | from .clienttest import ClusterTestCase, crash, wait, skip_without | |
|
29 | 29 | |
|
30 | 30 | def setup(): |
|
31 | 31 | add_engines(3) |
|
32 | 32 | |
|
33 | 33 | class TestView(ClusterTestCase): |
|
34 | 34 | |
|
35 |
def test_ |
|
|
35 | def test_crash_task(self): | |
|
36 | 36 | """test graceful handling of engine death (balanced)""" |
|
37 | 37 | # self.add_engines(1) |
|
38 |
ar = self.client[-1].apply_async( |
|
|
38 | ar = self.client[-1].apply_async(crash) | |
|
39 | 39 | self.assertRaisesRemote(error.EngineError, ar.get) |
|
40 | 40 | eid = ar.engine_id |
|
41 | while eid in self.client.ids: | |
|
41 | tic = time.time() | |
|
42 | while eid in self.client.ids and time.time()-tic < 5: | |
|
42 | 43 | time.sleep(.01) |
|
43 | 44 | self.client.spin() |
|
45 | self.assertFalse(eid in self.client.ids, "Engine should have died") | |
|
44 | 46 | |
|
45 |
def test_ |
|
|
47 | def test_crash_mux(self): | |
|
46 | 48 | """test graceful handling of engine death (direct)""" |
|
47 | 49 | # self.add_engines(1) |
|
48 | 50 | eid = self.client.ids[-1] |
|
49 |
ar = self.client[eid].apply_async( |
|
|
51 | ar = self.client[eid].apply_async(crash) | |
|
50 | 52 | self.assertRaisesRemote(error.EngineError, ar.get) |
|
51 | 53 | eid = ar.engine_id |
|
52 | while eid in self.client.ids: | |
|
54 | tic = time.time() | |
|
55 | while eid in self.client.ids and time.time()-tic < 5: | |
|
53 | 56 | time.sleep(.01) |
|
54 | 57 | self.client.spin() |
|
58 | self.assertFalse(eid in self.client.ids, "Engine should have died") | |
|
55 | 59 | |
|
56 | 60 | def test_push_pull(self): |
|
57 | 61 | """test pushing and pulling""" |
General Comments 0
You need to be logged in to leave comments.
Login now