def main(reactor): reactor.jobs.schedule(30, reactor.stop) print "write something: ", stdin = BufferedTransport(reactor.io.stdin) data = yield stdin.read_line(True) print "got", repr(data) reactor.stop()
def start(self): conn = BufferedTransport(self.conn) while True: line = yield conn.read_line() if line is None: break yield conn.write(line) yield conn.flush()
def __init__(self, reactor, proc, cmdline): self.reactor = reactor self.cmdline = cmdline self._proc = proc self.stdin = BufferedTransport( self.reactor.io._wrap_pipe(proc.stdin, "w")) self.stdout = BufferedTransport( self.reactor.io._wrap_pipe(proc.stdout, "r")) self.stderr = BufferedTransport( self.reactor.io._wrap_pipe(proc.stderr, "r")) self.pid = proc.pid self.wait_dfr = ReactorDeferred(self.reactor)
def main(reactor): reactor.jobs.schedule(2, reactor.stop) server = yield reactor.net.serve(EchoHandler, 12345) client = yield reactor.net.connect_tcp("localhost", 12345) client = BufferedTransport(client) for line in ["hello world\n", "foo bar\n", "spam bacon and eggs\n"]: yield client.write(line) yield client.flush() line2 = yield client.read_line() print repr(line) print repr(line2) print server.close() # causes ERROR_NETNAME_DELETED in GetQueuedCompletionStatus