Message232137
How it looks to me. Should be global collection of weak references (WeakSet?).
Every instance of TextIOWrapper, BufferedWriter and BufferedRandom add itself to
this collection on create and remove on close. A function registered with
atexit calls flush() for all methods in the collection.
This solution doesn't require changes to finalization machinery, only to the io
module.
I'm not particularly interested to implement that because I'm not convinced
that Python should provide such guaranties. But the implementation shouldn't
be too complex.
More general solution could be to introduce special method (__predel__) which
should be called before breaking reference loops (or just before __del__ if
there is no loop). In case of output streams it will call flush() (but not
close()!). |
|
Date |
User |
Action |
Args |
2014-12-04 13:39:37 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, tim.peters, arigo, pitrou, vstinner, nikratio, neologix |
2014-12-04 13:39:37 | serhiy.storchaka | link | issue17852 messages |
2014-12-04 13:39:36 | serhiy.storchaka | create | |
|