Skip to content

Fix: SQS polling_interval transport option ignored in async event loop #2439#2489

Open
ChickenBenny wants to merge 3 commits intocelery:mainfrom
ChickenBenny:fix/2439-polling-interval-not-work
Open

Fix: SQS polling_interval transport option ignored in async event loop #2439#2489
ChickenBenny wants to merge 3 commits intocelery:mainfrom
ChickenBenny:fix/2439-polling-interval-not-work

Conversation

@ChickenBenny
Copy link
Contributor

Summary

Fixes #2439 — the polling_interval broker transport option was completely ignored for SQS. Regardless of whether any messages were received, the poller would immediately reschedule the next ReceiveMessage call via hub.call_soon(), causing SQS to be polled as fast as the network allows (limited only by wait_time_seconds long-polling).

Root Cause

The SQS transport has its own async event-loop path that bypasses the polling_interval sleep used by virtual.Transport.drain_events(). The call chain was:

basic_consume
  └─ _loop1(queue)
       └─ hub.call_soon(_schedule_queue)        # schedules immediately
            └─ _get_bulk_async(callback=promise(_loop1, (queue,)))
                 └─ SQS ReceiveMessage
                      └─ _on_messages_ready()   # no return value
                           └─ _loop1(queue)     # always call_soon → infinite tight loop

Two concrete bugs:

  1. _loop1 always called hub.call_soon() — meaning the next poll was always scheduled immediately, regardless of whether the previous poll returned any messages.
  2. _on_messages_ready had no return value — so the callback (_loop1) could never know whether messages were found, making it impossible to decide whether to wait.

Behaviour After Fix

Scenario Before After
Empty poll Immediately polls again Waits polling_interval seconds (default: 1s)
Successful poll Immediately polls again Immediately polls again ✓
polling_interval=0 or None Immediately polls again Immediately polls again ✓
First basic_consume call Immediately polls Immediately polls ✓
Custom polling_interval=5 Ignored Waits 5 s between empty polls ✓

Related

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.29%. Comparing base (156e003) to head (cd9b510).
⚠️ Report is 6 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2489      +/-   ##
==========================================
+ Coverage   82.22%   82.29%   +0.07%     
==========================================
  Files          79       79              
  Lines       10077    10089      +12     
  Branches     1152     1152              
==========================================
+ Hits         8286     8303      +17     
+ Misses       1589     1584       -5     
  Partials      202      202              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@auvipy auvipy requested review from auvipy and Copilot March 14, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQS polling_interval broker transport option ignored.

1 participant