Skip to main content
added 87 characters in body
Source Link
grawity
  • 518.3k
  • 69
  • 1.1k
  • 1.2k

Python file writes are buffered, so even though you keep calling Python's write(), the underlying OS write() system call isn't called until the in-memory buffer fills, or the file is closed.

If you can edit the Python script, you should add a flush() after each write, and/or open the file in line-buffered mode

Flush:

f.write(sFileDate + ";" + sHeader)
f.write("\r\n")
f.flush()

Line-buffered mode:

f = open(sFile, "a", buffering=1)

f = open(sFile, "a", buffering=1)

Python file writes are buffered, so write() isn't called until the in-memory buffer fills, or the file is closed.

If you can edit the Python script, you should add a flush() after each write, and/or open the file in line-buffered mode

Flush:

f.write(sFileDate + ";" + sHeader)
f.write("\r\n")
f.flush()

Line-buffered mode:

f = open(sFile, "a", buffering=1)

Python file writes are buffered, so even though you keep calling Python's write(), the underlying OS write() system call isn't called until the in-memory buffer fills, or the file is closed.

If you can edit the Python script, you should add a flush() after each write, and/or open the file in line-buffered mode

Flush:

f.write(sFileDate + ";" + sHeader)
f.write("\r\n")
f.flush()

Line-buffered mode:

f = open(sFile, "a", buffering=1)
Source Link
spikey_richie
  • 10k
  • 4
  • 32
  • 58

Python file writes are buffered, so write() isn't called until the in-memory buffer fills, or the file is closed.

If you can edit the Python script, you should add a flush() after each write, and/or open the file in line-buffered mode

Flush:

f.write(sFileDate + ";" + sHeader)
f.write("\r\n")
f.flush()

Line-buffered mode:

f = open(sFile, "a", buffering=1)