I wrote my first code with Google Task Queue Python API. It is supposed to send out an email every time URL is entered into the address bar. Although it shows a task in default task queue in my dashboard, I don’t know why is it not executed even after an hour of initiating it.
queue-mail.py:-
class sendMail(webapp.RequestHandler):
def post(self):
mail.send_mail(
'X@gmail.com',
self.request.get('to'),
self.request.get('subject'),
self.request.get('body'))
taskqueue.add(url='/sendMail',params=dict(
to='Y@hotmail.com',
subject = 'Testing task queues',
body = 'this is a message!'))
app.yaml:-
handlers:
- url: /mail
script: queue-mail.py
I invoked the code as: appid.appspot.com/mail
Seeing as your problem is solved, I figured I’d post an official answer.
postworked whilegetdidn’t because that is the default method for task queue. If you look at the function documentation, one of the kwargs is method, in which you can specify get/post/etc, but as you didn’t in your code, it defaulted to post. As a side note, you probably didn’t see a 404 for a missing handler, but a 405 for “method not allowed” (since the task queue was trying to send a post request to a handler that didn’t have a post function defined)