Skip to content

Commit d0c85e4

Browse files
dcolascionepre-commit-ci[bot]A5rocks
authored
Add warning about non-blocking mode and TTYs (#3315)
* Add warning about non-blocking mode and TTYs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * streamline warning message * Make it shorter * Update _unix_pipes.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: A5rocks <[email protected]>
1 parent 732f157 commit d0c85e4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/trio/_unix_pipes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ def close(self) -> None:
8181

8282
@final
8383
class FdStream(Stream):
84-
"""
85-
Represents a stream given the file descriptor to a pipe, TTY, etc.
84+
"""Represents a stream given the file descriptor to a pipe, TTY, etc.
8685
8786
*fd* must refer to a file that is open for reading and/or writing and
8887
supports non-blocking I/O (pipes and TTYs will work, on-disk files probably
@@ -106,6 +105,15 @@ class FdStream(Stream):
106105
<https://github.com/python-trio/trio/issues/174>`__ for a discussion of the
107106
challenges involved in relaxing this restriction.
108107
108+
.. warning:: one specific consequence of non-blocking mode
109+
applying to the entire open file description is that when
110+
your program is run with multiple standard streams connected to
111+
a TTY (as in a terminal emulator), all of the streams become
112+
non-blocking when you construct an `FdStream` for any of them.
113+
For example, if you construct an `FdStream` for standard input,
114+
you might observe Python loggers begin to fail with
115+
`BlockingIOError`.
116+
109117
Args:
110118
fd (int): The fd to be wrapped.
111119

0 commit comments

Comments
 (0)