Questions tagged [flush]

Flush means clearing all the buffers for a stream. This will cause any buffered data to be written to the underlying device.

Flush means clearing all the buffers for a stream. This will cause any buffered data to be written to the underlying device.

1132 questions
1573
votes
13 answers

How can I flush the output of the print function?

How do I force Python's print function to flush the buffered output to the screen? See also: Disable output buffering if the goal is to change the buffering behaviour generally. This question is about explicitly flushing output after a specific…
Walter Nissen
  • 16,451
  • 4
  • 26
  • 27
684
votes
10 answers

Why does printf not flush after the call unless a newline is in the format string?

Why does printf not flush after the call unless a newline is in the format string? Is this POSIX behavior? How might I have printf immediately flush every time?
Crazy Chenz
  • 12,650
  • 12
  • 50
  • 62
286
votes
5 answers

How often does python flush to a file?

How often does Python flush to a file? How often does Python flush to stdout? I'm unsure about (1). As for (2), I believe Python flushes to stdout after every new line. But, if you overload stdout to be to a file, does it flush as often?
Tim McJilton
  • 6,884
  • 6
  • 25
  • 27
189
votes
4 answers

NHibernate ISession Flush: Where and when to use it, and why?

One of the things that get me thoroughly confused is the use of session.Flush,in conjunction with session.Commit, and session.Close. Sometimes session.Close works, e.g., it commits all the changes that I need. I know I need to use commit when I have…
Jon Limjap
  • 94,284
  • 15
  • 101
  • 152
154
votes
7 answers

What is the purpose of flush() in Java streams?

In Java, flush() method is used in streams. But I don't understand what are all the purpose of using this method? fin.flush(); tell me some suggestions.
Venkat
  • 20,802
  • 26
  • 75
  • 84
132
votes
3 answers

What does flushing the buffer mean?

I am learning C++ and I found something that I can't understand: Output buffers can be explicitly flushed to force the buffer to be written. By default, reading cin flushes cout; cout is also flushed when the program ends normally. So flushing…
Mohamed Ahmed Nabil
  • 3,949
  • 8
  • 36
  • 49
114
votes
19 answers

How can I clear an input buffer in C?

I have the following program: int main(int argc, char *argv[]) { char ch1, ch2; printf("Input the first character:"); // Line 1 scanf("%c", &ch1); printf("Input the second character:"); // Line 2 ch2 = getchar(); …
ipkiss
  • 13,311
  • 33
  • 88
  • 123
113
votes
13 answers

Force flushing of output to a file while bash script is still running

I have a small script, which is called daily by crontab using the following command: /homedir/MyScript &> some_log.log The problem with this method is that some_log.log is only created after MyScript finishes. I would like to flush the output of…
olamundo
  • 23,991
  • 34
  • 108
  • 149
83
votes
4 answers

PHP buffer ob_flush() vs. flush()

What's the difference between ob_flush() and flush() and why must I call both? The ob_flush() reference says: This function will send the contents of the output buffer (if any). The flush() reference says: Flushes the write buffers of PHP and…
Ben
  • 54,723
  • 49
  • 178
  • 224
74
votes
18 answers

How to flush output after each `echo` call?

I have a php script that only produces logs to the client. When I echo something, I want it to be transferred to client on-the-fly. (Because while the script is processing, the page is blank) I had already played around with ob_start() and…
cusspvz
  • 5,143
  • 7
  • 30
  • 45
73
votes
2 answers

Does python logging flush every log?

When I write a log to file using the standard module logging, will each log be flushed to disk separately? For example, will the following code flush log by 10 times? logging.basicConfig(level=logging.DEBUG, filename='debug.log') for i in…
Vincent Xue
  • 969
  • 1
  • 7
  • 17
60
votes
3 answers

Is there a way to programmably flush the buffer in log4net

I'm using log4net with AdoNetAppender. It's seems that the AdoNetAppender has a Flush method. Is there anyway I can call that from my code? I'm trying to create an admin page to view all the entries in the database log, and I will like to setup…
Henrik Stenbæk
  • 3,982
  • 5
  • 31
  • 33
57
votes
2 answers

c++ force std::cout flush (print to screen)

I have code such as the following: std::cout << "Beginning computations..."; // output 1 computations(); std::cout << " done!\n"; // output 2 The problem, however, is that often output #1 and output #2 appear (virtually)…
synaptik
  • 8,971
  • 16
  • 71
  • 98
55
votes
8 answers

How to prevent BrokenPipeError when doing a flush in Python?

Question: Is there a way to use flush=True for the print() function without getting the BrokenPipeError? I have a script pipe.py: for i in range(4000): print(i) I call it like this from a Unix command line: python3 pipe.py | head -n3000 And it…
tommy.carstensen
  • 8,962
  • 15
  • 65
  • 108
50
votes
2 answers

Do you need to call Flush() on a stream or writer if you are using the “using” statement?

I am not sure whether I need to call Flush() on the used objects if I write something like this: using (FileStream...) using (CryptoStream...) using (BinaryWriter...) { // do something } Are they always automatically flushed? When does the…
Ben
  • 2,435
  • 6
  • 43
  • 57
1
2 3
75 76