def test(self): c = cio.channel() cio.routine(self.reader, c) cio.routine(self.writer, c) cio.nonblock(1) for i in range(10): cio.write(1, "%d\n" % i)
def server(self, listener, count): for i in range(count): socketfd = cio.accept(listener.fileno()) print("accept() -> %d" % socketfd) cio.routine(self.server_handle, socketfd) listener.close() for i in range(10000): cio.write(1, "")
def test(self): count = 8 address = "", 1234 listener = socketlib.socket(socketlib.AF_INET, socketlib.SOCK_STREAM) listener.bind(address) listener.listen(socketlib.SOMAXCONN) for i in range(count): cio.routine(self.client, address, i) self.server(listener, 8)
def test(self): count = 8 pipe = os.pipe() cio.nonblock(pipe[0]) cio.nonblock(pipe[1]) for i in range(count): cio.routine(self.writer, os.dup(pipe[1]), i) self.reader(pipe[0], count) cio.close(pipe[0]) cio.close(pipe[1])