SQS Queues and more Simple DB

2 minute read

Apparently I need to send json to an SQS queue. It’s described at http://globalconstant.scnay.com/2011/03/02/programming-sqs-with-python-and-boto/, and http://classes.windley.com/462/wiki/index.php/SQS_Queues.
So I replaced the necessary fields with content specific to the ‘commentprocess’ in sqs. Still, while it doesn’t throw any errors, I’m not seeing my messages being posted into the queue, so I’m not sure if it’s working. Yuck
SO I came back to it, didn’t change anything, just ran it again and saw my comment was added to the queue. I think it was just getting popped out of the queue before it was being read before.
So now, I have to add the comment to simple db. I do that in just the same way as I saved new ratings, as shown on http://cloudcarpenters.com/blog/simpledb_primer_with_python_and_boto/.
The next part of teh lab required me to again add something to the simple db database, but teh catch was that it’s an image and I needed to inform the db of the image’s height and width. Well, all I was given was a url! How should I know?!
But a quick google search revealed a forum with the answer (the first reply didn’t actually work, as noted later in the thread, but teh second did): http://osdir.com/ml/python.image/2004-04/msg00052.html
Ok so now I’m adding a daemon to run every few seconds to process messages in the comment or image queues, and according to what those messages say, I’ll approve comments and images.
I’m following the instructions here:http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
I downloaded the two files, put themin the same folder, and they work basically as is. (One difficult thing though: the daemon (I suppoes obviously) runs in a different process than the shell from which it was called, so you can’t print out debug lines to it. I suppose I could configure it to still output to the same logfile I’ve been using, but that requires extra learning. No, for now I’m just going to get the code to work in a function where I can see the output and logs, and then paste it into the daemon function’s “run” method.
Now I need to read and pop from the queues.
I just noticed on the lab’s page, at the very bottom, that there’s an endpoint (a url I call and get a result from) to

Leave a Reply