def testWithoutPatch(self): a, b = coio.socketpair() pid = unpatched_fork() if pid: # Parent. try: a = a.dup() b = b.dup() RunWorker(b, a, self.MAX_SIZE) finally: got_pid, status = os.waitpid(pid, 0) assert got_pid == pid assert status == 0, 'child exited with status 0x%x' % status else: try: # Without coio.reinit() this the child may crash (segfault) or time # out. coio.reinit() RunWorker(a, b, self.MAX_SIZE) os._exit(0) except: sys.stderr.write(sys.exc_info()) os._exit(1)
if __name__ == '__main__': a, b = coio.socketpair() select_function = coio.select #a, b = socket.socketpair() #select_function = select.select #a, b = socket.socketpair() max_size = min(coio.max_nonblocking_pipe_write_size, 20000) # So we don't lose characters when writing the output to a file. EnableAppendMode(sys.stdout) EnableAppendMode(sys.stderr) pid = os.fork() # signal.alarm(10) won't help here. if pid: # Parent. try: a = a.dup() b = b.dup() RunWorker(b, a, max_size, 'P', select_function) finally: got_pid, status = os.waitpid(pid, 0) assert got_pid == pid assert status == 0, 'child exited with status 0x%x' % status print >> sys.stderr, 'ok' else: if len(sys.argv) > 1: coio.reinit() RunWorker(a, b, max_size, 'C', select_function) raise SystemExit
sys.stdout.flush() if __name__ == '__main__': a, b = coio.socketpair() select_function = coio.select #a, b = socket.socketpair() #select_function = select.select #a, b = socket.socketpair() max_size = min(coio.max_nonblocking_pipe_write_size, 20000) # So we don't lose characters when writing the output to a file. EnableAppendMode(sys.stdout) EnableAppendMode(sys.stderr) pid = os.fork() # signal.alarm(10) won't help here. if pid: # Parent. try: a = a.dup() b = b.dup() RunWorker(b, a, max_size, 'P', select_function) finally: got_pid, status = os.waitpid(pid, 0) assert got_pid == pid assert status == 0, 'child exited with status 0x%x' % status print >>sys.stderr, 'ok' else: if len(sys.argv) > 1: coio.reinit() RunWorker(a, b, max_size, 'C', select_function) raise SystemExit