Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Failure during the print of select.select output with unblocking sys.stdin  #126468

Open
@yurivict

Description

@yurivict

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions