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.

Author indygreg
Recipients indygreg
Date 2019-02-26.21:47:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551217633.94.0.247260600398.issue36129@roundup.psfhosted.org>
In-reply-to
Content
As part of implementing io.RawIOBase/io.BufferedIOBase compatible stream types for python-zstandard, I became confused about the expected behavior of flush() and close() when a stream is wrapping another stream.

The documentation doesn't lay out explicitly when flush() and close() on the outer stream should be proxied to the inner stream, if ever.

Here are some specific questions (it would be great to have answers to these in the docs):

1. When flush() is called on the outer stream, should flush() be called on the inner stream as well? Or should we simply write() to the inner stream and not perform a flush() on that inner stream?

2. When close() is called on the outer stream, should close() be called on the inner stream as well?

3. If close() is not automatically called on the inner stream during an outer stream's close(), should the outer stream trigger a flush() or any other special behavior on the inner stream? Or should it just write() any lingering data and then go away?

4. Are any of the answers from 1-3 impacted by whether the stream is a reader or writer? (Obviously reader streams don't have a meaningful flush() implementation.)

5. Are any of the answers from 1-3 impacted by whether the stream is in blocking/non-blocking mode?

6. Do any of the answers from 1-3 vary depending on whether behavior is incurred by the outer stream's __exit__?

(This issue was inspired by https://github.com/indygreg/python-zstandard/issues/76.)
History
Date User Action Args
2019-02-26 21:47:13indygregsetrecipients: + indygreg
2019-02-26 21:47:13indygregsetmessageid: <1551217633.94.0.247260600398.issue36129@roundup.psfhosted.org>
2019-02-26 21:47:13indygreglinkissue36129 messages
2019-02-26 21:47:13indygregcreate