Last active
May 22, 2018 09:24
-
-
Save Kiollpt/3da5a950c4b4a3fde1a58a589eeb665f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqs= boto3.resource('sqs', aws_access_key_id = AWS_ACCESS_KEY_ID, | |
aws_secret_access_key = AWS_SECRET_ACCESS_KEY, | |
region_name = REGION_NAME) | |
def receive_message_from_sqs(spider,delete=True): | |
queue = sqs.get_queue_by_name(QueueName=spider) | |
rows = [] | |
while True: | |
msgs=queue.receive_messages() | |
if len(msgs) == 0: | |
print('There is no message from sqs') | |
return rows | |
print(msgs) | |
for msg in msgs: | |
rows.append(json.loads(msg.body)['keywords']) | |
if delete: | |
msg.delete() | |
return rows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment