Reputation: 305
Here's my Python code right now:
sqs = boto3.resource('sqs')
queue = sqs.get_queue_by_name(Queue='test')
msg = 'hello world'
for i in range(0,1000):
queue.send_message(MessageBody = msg)
print("Message Sent")
And here is the Node.js version:
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
MessageBody: 'hello world',
QueueUrl: // Queue URL here
};
for(var i = 0; i < 1000; i++){
sqs.sendMessage(params, function(err,data){
if(err){
throw err;
} else {
console.log("Message Sent");
}
})
}
My problem is that it takes significantly longer to send 1000 messages using the Python script because it runs synchronously vs Node.js doing it asynchronously. I've looked everywhere and I can't seem to find any way to send messages asynchronously in Python. Insight would be greatly appreciated.
Upvotes: 3
Views: 6216
Reputation: 348
I would like to suggest my own Python package for this: it uses just aiohttp and lxml, without any boto-dependencies. https://github.com/d3QUone/aiosqs
Upvotes: 1
Reputation: 81336
The boto3 library does not support async calls. There is a library that supports S3 with some testing on SQS called aiobotocore. These links have more information:
Upvotes: 4