[issue17852] Built-in module _io can lose data from buffered files at exit

Neil Schemenauer report at bugs.python.org
Tue Dec 19 15:42:52 EST 2017


Neil Schemenauer <nas-python at arctrix.com> added the comment:

Yeah, I think you are correct.  Currently files not part of reference cycles get properly flushed and closed by the reference counter.  Implementing my "buffer_register_flush" patch would cause files to be closed only by the cyclic garbage collector (if not explicitly closed).  That would mean a script that opens a large number of files could run out of file descriptors.  Basically, we lose one of the main advantages of reference counting.

Probably the GC should keep track of how many files are open and call collect() when a threshold is reached.  Still, forcing every file to be collected only by the cyclic GC seems too ugly of a solution to this issue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue17852>
_______________________________________


More information about the Python-bugs-list mailing list