I'm working on an application whose workflow is managed by passing messages in SQS, using boto.
My SQS queue is growing gradually, and I have no way to check how many elements it is supposed to contain.
Now I have a daemon that periodically polls the queue, and checks if i have a fixed-size set of elements. For example, consider the following "queue":
q = ["msg1_comp1", "msg2_comp1", "msg1_comp2", "msg3_comp1", "msg2_comp2"]
>>> rs = q.get_messages()
>>> rs = q.get_messages(10)
Put your call to
q.get_messages(n) inside while loop:
all_messages= rs=q.get_messages(10) while len(rs)>0: all_messages.extend(rs) rs=q.get_messages(10)
Additionally, dump won't support more than 10 messages either:
def dump(self, file_name, page_size=10, vtimeout=10, sep='\n'): """Utility function to dump the messages in a queue to a file NOTE: Page size must be < 10 else SQS errors"""