Gets a list of SQS queues. When a prefix is specified, only queues with names that start with the prefix are returned. :param prefix: The prefix used to restrict the list of returned queues. :return: A list of Queue objects.
(prefix=None)
| 70 | |
| 71 | # snippet-start:[python.example_code.sqs.ListQueues] |
| 72 | def get_queues(prefix=None): |
| 73 | """ |
| 74 | Gets a list of SQS queues. When a prefix is specified, only queues with names |
| 75 | that start with the prefix are returned. |
| 76 | |
| 77 | :param prefix: The prefix used to restrict the list of returned queues. |
| 78 | :return: A list of Queue objects. |
| 79 | """ |
| 80 | if prefix: |
| 81 | queue_iter = sqs.queues.filter(QueueNamePrefix=prefix) |
| 82 | else: |
| 83 | queue_iter = sqs.queues.all() |
| 84 | queues = list(queue_iter) |
| 85 | if queues: |
| 86 | logger.info("Got queues: %s", ", ".join([q.url for q in queues])) |
| 87 | else: |
| 88 | logger.warning("No queues found.") |
| 89 | return queues |
| 90 | |
| 91 | |
| 92 | # snippet-end:[python.example_code.sqs.ListQueues] |