##// END OF EJS Templates
use crash that will also kill a Windows engine...
MinRK -
Show More
@@ -29,6 +29,17 b' def segfault():'
29 import ctypes
29 import ctypes
30 ctypes.memset(-1,0,1)
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 def wait(n):
43 def wait(n):
33 """sleep for a time"""
44 """sleep for a time"""
34 import time
45 import time
@@ -86,7 +97,7 b' class ClusterTestCase(BaseZMQTestCase):'
86 except error.CompositeError as e:
97 except error.CompositeError as e:
87 e.raise_exception()
98 e.raise_exception()
88 except error.RemoteError as e:
99 except error.RemoteError as e:
89 self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(e.ename, etype.__name__))
100 self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename))
90 else:
101 else:
91 self.fail("should have raised a RemoteError")
102 self.fail("should have raised a RemoteError")
92
103
@@ -25,33 +25,37 b' from IPython.parallel.util import interactive'
25
25
26 from IPython.parallel.tests import add_engines
26 from IPython.parallel.tests import add_engines
27
27
28 from .clienttest import ClusterTestCase, segfault, wait, skip_without
28 from .clienttest import ClusterTestCase, crash, wait, skip_without
29
29
30 def setup():
30 def setup():
31 add_engines(3)
31 add_engines(3)
32
32
33 class TestView(ClusterTestCase):
33 class TestView(ClusterTestCase):
34
34
35 def test_segfault_task(self):
35 def test_crash_task(self):
36 """test graceful handling of engine death (balanced)"""
36 """test graceful handling of engine death (balanced)"""
37 # self.add_engines(1)
37 # self.add_engines(1)
38 ar = self.client[-1].apply_async(segfault)
38 ar = self.client[-1].apply_async(crash)
39 self.assertRaisesRemote(error.EngineError, ar.get)
39 self.assertRaisesRemote(error.EngineError, ar.get)
40 eid = ar.engine_id
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 time.sleep(.01)
43 time.sleep(.01)
43 self.client.spin()
44 self.client.spin()
45 self.assertFalse(eid in self.client.ids, "Engine should have died")
44
46
45 def test_segfault_mux(self):
47 def test_crash_mux(self):
46 """test graceful handling of engine death (direct)"""
48 """test graceful handling of engine death (direct)"""
47 # self.add_engines(1)
49 # self.add_engines(1)
48 eid = self.client.ids[-1]
50 eid = self.client.ids[-1]
49 ar = self.client[eid].apply_async(segfault)
51 ar = self.client[eid].apply_async(crash)
50 self.assertRaisesRemote(error.EngineError, ar.get)
52 self.assertRaisesRemote(error.EngineError, ar.get)
51 eid = ar.engine_id
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 time.sleep(.01)
56 time.sleep(.01)
54 self.client.spin()
57 self.client.spin()
58 self.assertFalse(eid in self.client.ids, "Engine should have died")
55
59
56 def test_push_pull(self):
60 def test_push_pull(self):
57 """test pushing and pulling"""
61 """test pushing and pulling"""
General Comments 0
You need to be logged in to leave comments. Login now