Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python examples of how to use waiter function on AWS SQS

I am trying to use the waiter functionality available for SQS on AWS. However, I have not seen any documentation and python examples of this works

AWS Boto / SQS documentation link referring to Waiter here: http://boto3.readthedocs.io/en/latest/guide/clients.html#waiters, but does not give any detailed examples using SQS

Any guidance appreciated

like image 420
nnay84 Avatar asked Oct 24 '25 16:10

nnay84


2 Answers

SQS does not have waiters in boto3.

Note if a client does not have any waiters, it will return an empty list when accessing its waiter_names attribute.

import boto3
sqs = boto3.client('sqs')
sqs.waiter_names
[]
like image 77
Eytan Avisror Avatar answered Oct 26 '25 05:10

Eytan Avisror


I understand you're looking for a high level way to listen to SQS queues from Python code:

multi_sqs_listener may help you achieve this (disclosure: I'm the author):

from multi_sqs_listener import QueueConfig, EventBus, MultiSQSListener

class MyListener(MultiSQSListener):
    def handle_message(self, queue, bus, priority, message):
        # This is where your actual event handler code will sit
        print(message.body)

my_event_bus = EventBus()
EventBus.register_buses([my_event_bus])

my_queue = QueueConfig('my-queue', my_event_bus)
my_listener = MyListener([my_queue])
my_listener.listen()
like image 45
fabien Avatar answered Oct 26 '25 04:10

fabien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!