How to control I/O buffering besides -u?

K

kj

Is there any way to specify unbuffered I/O from *within* the code
(rather than via the command-line -u flag)?

TIA!

kynn
 
D

Dave Angel

kj said:
Is there any way to specify unbuffered I/O from *within* the code
(rather than via the command-line -u flag)?

TIA!

kynn
When creating a file object, specify a buffer size of zero. I don't
know how to change the buffering of a file object that's already been
created, as stdin, stdout, and stderr are.

DaveA
 
M

Matt Joiner

You can try flushing, or reopening with no buffering

sys.stdout.flush()
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,196
Messages
2,571,036
Members
47,631
Latest member
kukuh

Latest Threads

Top