diff options
author | Neil Schemenauer <nas-github@arctrix.com> | 2017-09-04 22:13:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 22:13:17 -0700 |
commit | db564238db440d4a2d8eb9d60ffb94ef291f6d30 (patch) | |
tree | b543c66c80fbab511ec65f8fba03f6cf11bb3878 /Lib/_pyio.py | |
parent | e38d12ed34870c140016bef1e0ff10c8c3d3f213 (diff) | |
download | cpython-git-db564238db440d4a2d8eb9d60ffb94ef291f6d30.tar.gz |
Revert "bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (#1908)" (#3337)
This reverts commit e38d12ed34870c140016bef1e0ff10c8c3d3f213.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 3aa2b24c04..4653847bcb 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1185,7 +1185,6 @@ class BufferedWriter(_BufferedIOMixin): self.buffer_size = buffer_size self._write_buf = bytearray() self._write_lock = Lock() - _register_writer(self) def writable(self): return self.raw.writable() @@ -2575,26 +2574,3 @@ class StringIO(TextIOWrapper): def detach(self): # This doesn't make sense on StringIO. self._unsupported("detach") - - -# ____________________________________________________________ - -import atexit, weakref - -_all_writers = weakref.WeakSet() - -def _register_writer(w): - # keep weak-ref to buffered writer - _all_writers.add(w) - -def _flush_all_writers(): - # Ensure all buffered writers are flushed before proceeding with - # normal shutdown. Otherwise, if the underlying file objects get - # finalized before the buffered writer wrapping it then any buffered - # data will be lost. - for w in _all_writers: - try: - w.flush() - except: - pass -atexit.register(_flush_all_writers) |