def send_response(stream): print 'starting response' stream.write('there is no spoon\n', with_args(read_response, stream))
def read_response(stream): print 'reading' stream.read_until_close(with_args(consume_result, stream))
def _consume_len(self, data, stream, callback): length = int(data) stream.read_bytes(length, with_args(self._consume_data, callback))
def deserialize(self, stream, callback): stream.read_until(' ', with_args(self._consume_len, stream, callback))
def echo_handler(stream, address): print "Connection Received:", stream, "from", address stream.read_until('\n', with_args(echo_responder, stream))