(original) (raw)

import thread, os read_fd, write_fd = os.pipe() fread = os.fdopen(read_fd, 'rb') fwrite = os.fdopen(write_fd, 'wb') def writer(): print >> fwrite, range(100000) fwrite.flush() thread.start_new_thread(writer, ()) line = fread.readline() assert line == str(range(100000)) + '\n'