Failure during the print of select.select output with unblocking sys.stdin
Open
Nobody has claimed this yet.
extension-modules
topic-socket
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
This code terminates with error messages after several loop iterations:
import sys
import os
import select
os.set_blocking(sys.stdin.fileno(), False)
while True:
print('>')
ready = select.select([sys.stdin, ], [], [], 0.0)[0]
print(f'< ready={ready}')
$ python3.11 stdin-nonblocking-bug-report.py
<... skip many iterations ...>
< ready=[]
>
< ready=[]
>
< ready=[]
Traceback (most recent call last):
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
Exception ignored in sys.unraisablehook: <built-in function unraisablehook>
$ echo $?
120
The failure occurs in print(f'< ready={ready}').
Python-3.11
FreeBSD 14.1
CPython versions tested on:
3.11
Operating systems tested on:
Other
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided reproducer that sets sys.stdin nonblocking and repeatedly calls select.select before printing. Reproduce the failure on Python 3.11 with FreeBSD 14.1, then trace the stdout print and shutdown path to identify the cause. Done means the loop no longer produces the reported unraisable I/O error under the stated conditions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100