Am 05.03.23 um 15:35 schrieb aapost:
I have run in to this a few times and finally reproduced it. Whether it is as expected I am not sure since it is slightly on the user, but I can think of scenarios where this would be undesirable behavior.. This occurs on 3.11.1 and 3.11.2 using debian 12 testing, in case the reasoning lingers somewhere else.

If a file is still open, even if all the operations on the file have ceased for a time, the tail of the written operation data does not get flushed to the file until close is issued and the file closes cleanly.

2 methods to recreate - 1st run from interpreter directly:

f = open("abc", "w")
for i in range(50000):
   f.write(str(i) + "\n")

use

with open("abc", "w") as f:
    for i in range(50000):
        f.write(str(i) + "\n")

and all is well

Frank
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to