Repository navigation
fix(eventio): make _poll.poll(None) block indefinitely - #2862
Closed
tony1233200 wants to merge 2 commits into
Closed
tony1233200 wants to merge 2 commits into
tony1233200 wants to merge 2 commits into
Conversation
_poll.poll() converted the timeout with (timeout or 0), turning None into 0, so poll(None) returned immediately instead of blocking until an event arrives -- unlike _epoll (which passes -1), _kqueue and _select (which pass None through). On platforms without epoll (macOS, BSD), Connection.drain_events() with no timeout passes None down to _poll.poll(None), so an idle consumer busy-spins (the issue reports ~35k poll() calls in 3s while waiting for a single BRPOP reply). Pass -1 for a None timeout (select.poll treats a negative timeout as infinite); finite timeouts are still converted to milliseconds and negative timeouts still clamp to 0. Fixes celery#2834.
auvipy
requested changes
Nov 25, 2026
Member
There was a problem hiding this comment.
there was already and open PR #2786 under review for that issue, why you opend a duplicate one without checking, and by not checking the contribution guideline? are you real or just another bot contributor? @tony1233200 also you did some distracting drama recently which is very unprofessional. you have been marked as bot for these unprofessional activites
Member
|
@tony1233200 unblocked you again as 2nd chance |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2834.
Problem
kombu.utils.eventio._poll.poll()— the poller used whereverepollisunavailable (macOS, FreeBSD, OpenBSD) — converted its timeout with
round((timeout or 0) * 1e3), turningNoneinto0. Sopoll(None)called
select.poll().poll(0)and returned[]immediately instead ofblocking until an event arrives, unlike
_epoll(which passes-1forNone),_kqueue, and_select(which passNonethrough).On Redis,
Connection.drain_events()with no timeout passesNonedownthrough
MultiChannelPoller.get()to_poll.poll(None), so an idleconsumer on macOS/BSD busy-spins — the issue reports ~35k
poll()callsand ~3.5k
restore_visible()cycles in 3 s while waiting for a singleBRPOPreply.Fix
In
_poll.poll():timeout is None→ pass-1(select.polltreats a negative timeoutas infinite), mirroring
_epoll;timeout < 0→0, as before;round(timeout * 1e3)milliseconds, as before.Verified with the reproducer from the issue (using
_polldirectly):before —
poll(None)returned[]after 0.0 s; after — it returns[(fd, 1)]after 0.5 s, when the timer sends.Tests
New
test__pollclass int/unit/utils/test_eventio.py, mirroring theexisting
test__epolltests:test_poll_none_timeout_passes_minus_oneandtest_poll_none_timeout_blocks_until_event(a real socketpairend-to-end check) — both fail on the unpatched code and pass with the
fix;
negative timeouts still clamp to 0.
t/unit/utils/— 173 passed;t/unit/asynchronous/(excluding theawsmodules, which need
boto3) — 95 passed, 2 skipped.flake8clean onthe changed files.
Disclosure: this patch was prepared with the help of an AI coding
assistant and reviewed/tested by me.