Cancellation Token for Long polling in SQS #3861
Labels
closed-for-staleness
feature-request
This issue requests a feature.
response-requested
Waiting on additional information or feedback.
sqs
Use Case
In documentation in boto3 for SQS, receive_message() function have "WaitTimeSeconds" parameter to activate long polling, So that we can save cost for calling API.
But since boto3 is non-async(synchronously executing) and blocking main thread,
When I set threading.Event or asyncio.Event to stop infinite loop for stopping background daemon task, receive_message() still waiting for next message (when queue is empty).
So, main service thread (like RESTful API Service) can't stop until boto3 receiving empty message, and finally stopped.
Proposed Solution
Add the Cancellation Token to receive_message() to send the signal that client don't need to wait for next message, and immediately stop.
Other Information
No response
Acknowledgements
SDK version used
boto3 1.28.43
Environment details (OS name and version, etc.)
macos Ventura, python 3.11.3 with poetry
The text was updated successfully, but these errors were encountered: