Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/prompt_toolkit/input/posix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def __init__(
self, stdin_fd: int, errors: str = "surrogateescape", encoding: str = "utf-8"
) -> None:
self.stdin_fd = stdin_fd
self._polling_object = select.poll()
self._polling_object.register(self.stdin_fd)
self.errors = errors

# Create incremental decoder for decoding stdin.
Expand Down Expand Up @@ -69,7 +71,7 @@ def read(self, count: int = 1024) -> str:
# function is only called when there is something to read, but for some
# reason this happens in certain situations.)
try:
if not select.select([self.stdin_fd], [], [], 0)[0]:
if not self._polling_object.poll(0): # 0 = don't block
return ""
except OSError:
# Happens for instance when the file descriptor was closed.
Expand Down