Skip to content

Instantly share code, notes, and snippets.

@Kiollpt
Last active May 22, 2018 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kiollpt/3da5a950c4b4a3fde1a58a589eeb665f to your computer and use it in GitHub Desktop.
Save Kiollpt/3da5a950c4b4a3fde1a58a589eeb665f to your computer and use it in GitHub Desktop.
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