|
|
|
|
@ -2,7 +2,6 @@ import errno
|
|
|
|
|
import fcntl
|
|
|
|
|
import os
|
|
|
|
|
import signal
|
|
|
|
|
import sys
|
|
|
|
|
import time
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
@ -21,23 +20,6 @@ except NameError:
|
|
|
|
|
from io import FileIO as file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wait_for_child(pid, timeout=1.0):
|
|
|
|
|
deadline = mitogen.core.now() + timeout
|
|
|
|
|
while timeout < mitogen.core.now():
|
|
|
|
|
try:
|
|
|
|
|
target_pid, status = os.waitpid(pid, os.WNOHANG)
|
|
|
|
|
if target_pid == pid:
|
|
|
|
|
return
|
|
|
|
|
except OSError:
|
|
|
|
|
e = sys.exc_info()[1]
|
|
|
|
|
if e.args[0] == errno.ECHILD:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
time.sleep(0.05)
|
|
|
|
|
|
|
|
|
|
assert False, "wait_for_child() timed out"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mitogen.core.takes_econtext
|
|
|
|
|
def call_func_in_sibling(ctx, econtext, sync_sender):
|
|
|
|
|
recv = ctx.call_async(time.sleep, 99999)
|
|
|
|
|
@ -106,7 +88,7 @@ class ReapChildTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
|
self.assertRaises(mitogen.core.TimeoutError,
|
|
|
|
|
lambda: conn.connect(context=mitogen.core.Context(None, 1234))
|
|
|
|
|
)
|
|
|
|
|
wait_for_child(conn.proc.pid)
|
|
|
|
|
testlib.wait_for_child(conn.proc.pid)
|
|
|
|
|
e = self.assertRaises(OSError,
|
|
|
|
|
lambda: os.kill(conn.proc.pid, 0)
|
|
|
|
|
)
|
|
|
|
|
@ -165,7 +147,7 @@ class ContextTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
|
local = self.router.local()
|
|
|
|
|
pid = local.call(os.getpid)
|
|
|
|
|
local.shutdown(wait=True)
|
|
|
|
|
wait_for_child(pid)
|
|
|
|
|
testlib.wait_for_child(pid)
|
|
|
|
|
self.assertRaises(OSError, lambda: os.kill(pid, 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|