Message310659
| Author |
njs |
| Recipients |
Arusekk, martin.panter, nascheme, neologix, nikratio, nitishch, njs, pitrou, serhiy.storchaka, tim.peters, vstinner, xgdomingo |
| Date |
2018年01月25日.07:19:13 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1516864754.42.0.467229070634.issue17852@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> 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__.
This may be a bit of a left-field or too-big-a-hammer suggestion, but as far I can tell from this thread [1] it probably is technically possible to modify the GC to clear weakrefs after calling __del__. Nick wasn't a fan (he likes the invariant that weakrefs can't trigger a resurrection), but if all else fails it might be worth re-raising.
You could add a secondary reference count on FileIO recording how many BufferedIO wrappers there are around it; then it's __del__ would skip calling close() if there are still BufferedIO wrappers, and BufferedIO.__del__ would decrement the reference count and close the underlying file if it hits zero and FileIO.__del__ had already been called.
[1] https://mail.python.org/pipermail/python-dev/2016-October/146747.html |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2018年01月25日 07:19:14 | njs | set | recipients:
+ njs, tim.peters, nascheme, pitrou, vstinner, nikratio, neologix, martin.panter, serhiy.storchaka, xgdomingo, nitishch, Arusekk |
| 2018年01月25日 07:19:14 | njs | set | messageid: <1516864754.42.0.467229070634.issue17852@psf.upfronthosting.co.za> |
| 2018年01月25日 07:19:14 | njs | link | issue17852 messages |
| 2018年01月25日 07:19:13 | njs | create |
|