➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 nascheme
收信人 martin.panter, nascheme, neologix, nikratio, nitishch, pitrou, serhiy.storchaka, tim.peters, vstinner, xgdomingo
日期 2017-12-19.18:42:23
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1513708943.75.0.213398074469.issue17852@psf.upfronthosting.co.za>
In-reply-to
内容
Welp, another day another attempt.  As mentioned in the PR 4847, atexit is not the answer.  If the raw/buffered file pair are part of a reference cycle and the GC cleans it before atexit runs, then the buffered data can get lost.

I attempted to implement my weakref idea (i.e. raw file keeps a weakref to the buffered file, calls flush before the raw file gets closed).  That doesn't work either because the GC clears the weakref before calling __del__.

The attached patch "buffer_register_flush.txt" does seem to work.  The downside is that it creates a reference cycle between the raw and buffered file objects.  Perhaps that is not a problem since unless you call close() on the raw file, you will be leaking resources anyhow.  In the patch, calling close() removes the reference cycle.

I still feel like this is worth fixing, as ugly as the implementation is.
历史
日期 用户 动作 参数
2017-12-19 18:42:23nascheme修改recipients: + nascheme, tim.peters, pitrou, vstinner, nikratio, neologix, martin.panter, serhiy.storchaka, xgdomingo, nitishch
2017-12-19 18:42:23nascheme修改messageid: <1513708943.75.0.213398074469.issue17852@psf.upfronthosting.co.za>
2017-12-19 18:42:23nascheme链接issue17852 messages
2017-12-19 18:42:23nascheme创建