Keyerror During Python Gae Push Task Queue With Cron
Solution 1:
When you call
fu = str(self.request.get('fu'))
if there is no 'fu' in the request, self.request.get will return the empty string (''). So when you try
messageid = fu_messages[fu]
it looks up the empty string in
fu_messages = {'1': 'MS_x01',
'2': 'MS_x02',
}
which only has '1' and '2' as keys.
The reason your pushQueue handler is not seeing the params you send via
params = {
'guid': guid,
'fu': follow_up,
'lang': lang,
'trigid': trigid,
}
taskqueue.add(queue_name='emailworker', url='/emailworker',
params=params)
is because you are using a GET handler instead of a POST or PUT handler. As the documentation states:
Params are encoded as
application/x-www-form-urlencodedand set to the payload.
So the payload of the request has your 'fu' param in it, but since it is a GET request, the payload is dropped (this is how HTTP works, not specific to App Engine). If you use POST as your handler, the payload will come through as expected.
I noticed your code is very similar to the documented sample, but simply uses get where the sample uses post.
Post a Comment for "Keyerror During Python Gae Push Task Queue With Cron"