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.

classification
Title: io.BufferedRWPair doc warning may need clarification
Type: behavior Stage:
Components: Documentation Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: benjamin.peterson, docs@python, pitrou, rgov, stutzbach
Priority: normal Keywords:

Created on 2019-10-26 05:19 by rgov, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg355404 - (view) Author: Ryan Govostes (rgov) Date: 2019-10-26 05:19
The documentation for the io.BufferedRWPair class gives this warning:

> BufferedRWPair does not attempt to synchronize accesses to its underlying raw streams. You should not pass it the same object as reader and writer; use BufferedRandom instead.

I have a hard time understanding what this warning is trying to tell me.

1. What does it mean to "synchronize accesses"?

2. Why can't I pass the same object as reader and writer? The docstring in _pyio.py says, "This is typically used with a socket or two-way pipe."

3. How does BufferedRandom, which adds the seek() and tell() interfaces, address the issue of "synchroniz[ing] accesses"? Is synchronization automatic? What does this do for sockets or pipes which cannot seek?
msg355405 - (view) Author: Ryan Govostes (rgov) Date: 2019-10-26 05:30
The origin of this warning involves interleaving read and write operations, and was added here: https://bugs.python.org/issue12213

I'm not sure if it applies to sockets, pipes, etc. though.

The pySerial documentation advises using io.BufferedRWPair(x, x) where x is a serial device. But this StackOverflow post reports that it is problematic, in line with the warning. (The author appears to be talking about Windows.)

https://stackoverflow.com/questions/24498048/python-io-modules-textiowrapper-or-buffererwpair-functions-are-not-playing-nice
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82776
2019-10-26 05:30:22rgovsetnosy: + pitrou, benjamin.peterson, stutzbach
messages: + msg355405
2019-10-26 05:19:33rgovcreate