|
|
@ -138,7 +138,7 @@ class StreamErrorTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def test_via_eof(self):
|
|
|
|
def test_via_eof(self):
|
|
|
|
# Verify FD leakage does not keep failed process open.
|
|
|
|
# Verify FD leakage does not keep failed process open.
|
|
|
|
local = self.router.fork()
|
|
|
|
local = self.router.local()
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
lambda: self.router.local(
|
|
|
|
lambda: self.router.local(
|
|
|
|
via=local,
|
|
|
|
via=local,
|
|
|
@ -160,7 +160,7 @@ class StreamErrorTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
self.assertTrue(e.args[0].startswith(prefix))
|
|
|
|
self.assertTrue(e.args[0].startswith(prefix))
|
|
|
|
|
|
|
|
|
|
|
|
def test_via_enoent(self):
|
|
|
|
def test_via_enoent(self):
|
|
|
|
local = self.router.fork()
|
|
|
|
local = self.router.local()
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
lambda: self.router.local(
|
|
|
|
lambda: self.router.local(
|
|
|
|
via=local,
|
|
|
|
via=local,
|
|
|
@ -265,9 +265,9 @@ class IterReadTest(testlib.TestCase):
|
|
|
|
proc = self.make_proc()
|
|
|
|
proc = self.make_proc()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
reader = self.func([proc.stdout.fileno()])
|
|
|
|
reader = self.func([proc.stdout.fileno()])
|
|
|
|
for i, chunk in enumerate(reader, 1):
|
|
|
|
for i, chunk in enumerate(reader):
|
|
|
|
self.assertEqual(i, int(chunk))
|
|
|
|
self.assertEqual(1+i, int(chunk))
|
|
|
|
if i > 3:
|
|
|
|
if i > 2:
|
|
|
|
break
|
|
|
|
break
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
Popen__terminate(proc)
|
|
|
|
Popen__terminate(proc)
|
|
|
@ -358,7 +358,7 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
def test_child_disconnected(self):
|
|
|
|
def test_child_disconnected(self):
|
|
|
|
# Easy mode: process notices its own directly connected child is
|
|
|
|
# Easy mode: process notices its own directly connected child is
|
|
|
|
# disconnected.
|
|
|
|
# disconnected.
|
|
|
|
c1 = self.router.fork()
|
|
|
|
c1 = self.router.local()
|
|
|
|
recv = c1.call_async(time.sleep, 9999)
|
|
|
|
recv = c1.call_async(time.sleep, 9999)
|
|
|
|
c1.shutdown(wait=True)
|
|
|
|
c1.shutdown(wait=True)
|
|
|
|
e = self.assertRaises(mitogen.core.ChannelError,
|
|
|
|
e = self.assertRaises(mitogen.core.ChannelError,
|
|
|
@ -368,8 +368,8 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
def test_indirect_child_disconnected(self):
|
|
|
|
def test_indirect_child_disconnected(self):
|
|
|
|
# Achievement unlocked: process notices an indirectly connected child
|
|
|
|
# Achievement unlocked: process notices an indirectly connected child
|
|
|
|
# is disconnected.
|
|
|
|
# is disconnected.
|
|
|
|
c1 = self.router.fork()
|
|
|
|
c1 = self.router.local()
|
|
|
|
c2 = self.router.fork(via=c1)
|
|
|
|
c2 = self.router.local(via=c1)
|
|
|
|
recv = c2.call_async(time.sleep, 9999)
|
|
|
|
recv = c2.call_async(time.sleep, 9999)
|
|
|
|
c2.shutdown(wait=True)
|
|
|
|
c2.shutdown(wait=True)
|
|
|
|
e = self.assertRaises(mitogen.core.ChannelError,
|
|
|
|
e = self.assertRaises(mitogen.core.ChannelError,
|
|
|
@ -379,8 +379,8 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
def test_indirect_child_intermediary_disconnected(self):
|
|
|
|
def test_indirect_child_intermediary_disconnected(self):
|
|
|
|
# Battlefield promotion: process notices indirect child disconnected
|
|
|
|
# Battlefield promotion: process notices indirect child disconnected
|
|
|
|
# due to an intermediary child disconnecting.
|
|
|
|
# due to an intermediary child disconnecting.
|
|
|
|
c1 = self.router.fork()
|
|
|
|
c1 = self.router.local()
|
|
|
|
c2 = self.router.fork(via=c1)
|
|
|
|
c2 = self.router.local(via=c1)
|
|
|
|
recv = c2.call_async(time.sleep, 9999)
|
|
|
|
recv = c2.call_async(time.sleep, 9999)
|
|
|
|
c1.shutdown(wait=True)
|
|
|
|
c1.shutdown(wait=True)
|
|
|
|
e = self.assertRaises(mitogen.core.ChannelError,
|
|
|
|
e = self.assertRaises(mitogen.core.ChannelError,
|
|
|
@ -390,8 +390,8 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
def test_near_sibling_disconnected(self):
|
|
|
|
def test_near_sibling_disconnected(self):
|
|
|
|
# Hard mode: child notices sibling connected to same parent has
|
|
|
|
# Hard mode: child notices sibling connected to same parent has
|
|
|
|
# disconnected.
|
|
|
|
# disconnected.
|
|
|
|
c1 = self.router.fork()
|
|
|
|
c1 = self.router.local()
|
|
|
|
c2 = self.router.fork()
|
|
|
|
c2 = self.router.local()
|
|
|
|
|
|
|
|
|
|
|
|
# Let c1 call functions in c2.
|
|
|
|
# Let c1 call functions in c2.
|
|
|
|
self.router.stream_by_id(c1.context_id).auth_id = mitogen.context_id
|
|
|
|
self.router.stream_by_id(c1.context_id).auth_id = mitogen.context_id
|
|
|
@ -412,11 +412,11 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
def test_far_sibling_disconnected(self):
|
|
|
|
def test_far_sibling_disconnected(self):
|
|
|
|
# God mode: child of child notices child of child of parent has
|
|
|
|
# God mode: child of child notices child of child of parent has
|
|
|
|
# disconnected.
|
|
|
|
# disconnected.
|
|
|
|
c1 = self.router.fork()
|
|
|
|
c1 = self.router.local()
|
|
|
|
c11 = self.router.fork(via=c1)
|
|
|
|
c11 = self.router.local(via=c1)
|
|
|
|
|
|
|
|
|
|
|
|
c2 = self.router.fork()
|
|
|
|
c2 = self.router.local()
|
|
|
|
c22 = self.router.fork(via=c2)
|
|
|
|
c22 = self.router.local(via=c2)
|
|
|
|
|
|
|
|
|
|
|
|
# Let c1 call functions in c2.
|
|
|
|
# Let c1 call functions in c2.
|
|
|
|
self.router.stream_by_id(c1.context_id).auth_id = mitogen.context_id
|
|
|
|
self.router.stream_by_id(c1.context_id).auth_id = mitogen.context_id
|
|
|
|