Whole file
redis/redis-py
The author described this change as “Fix hiredis readiness checks for high file descriptors (#4115)”. It counts as a record because the checks below fail on the code as it stood at 640f0d055 and pass on 2febde067, with nothing else changed between the two runs.
Projectredis/redis-py
Fix saved2026-06-11
Sharing licenceMIT · LICENSE
Change size+6 −2
What the code was meant to do, written into the code itself as a save note
Fix hiredis readiness checks for high file descriptors (#4115)
The change
| 1 | - | import select | |
| 1 | + | import selectors | |
| 2 | 2 | import socket | |
| 3 | 3 | from logging import getLogger | |
| 4 | 4 | from typing import Callable, List, Optional, TypedDict, Union | |
| ⋯ | |||
| 28 | 28 | # SSL sockets can have decrypted bytes buffered above the OS socket layer. | |
| 29 | 29 | if hasattr(sock, "pending") and sock.pending(): | |
| 30 | 30 | return True | |
| 31 | - | return bool(select.select([sock], [], [], timeout)[0]) | |
| 31 | + | # timeout=0 must be a non-blocking readiness check only. The selector keeps | |
| 32 | + | # this non-destructive while avoiding select.select's low fd limit on Unix. | |
| 33 | + | with selectors.DefaultSelector() as selector: | |
| 34 | + | selector.register(sock, selectors.EVENT_READ) | |
| 35 | + | return bool(selector.select(timeout)) | |
| 32 | 36 | ||
| 33 | 37 | ||
| 34 | 38 | class _HiredisReaderArgs(TypedDict, total=False): | |
The check that tells the two apart
fail→pass·tests/test_connection.py::test_hiredis_socket_can_read_handles_high_file_descriptor
fail→pass·tests/test_connection.py::test_hiredis_socket_can_read_uses_default_selector
Check file tests/test_connection.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it640f0d055f19a9203cc894998d97150676dbf947
Broken version dated2026-06-10
Moduleredis._parsers.hiredis
Units changed_socket_can_read
Fingerprint10a55e1d70179eda
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in redis/redis-py
- 2026-07-29Reducer
- 2026-07-28Fix lat/lon swap in search querystring geo() helper (#4223)
- 2026-07-03_HiredisParser