How to pass arguments to a python cron task on Google App Engine?

I have an application written in Python. It collects and parses data from certain sources (RSS, Atom, Twitter, etc.) and if new data is found, it's saved to a MySQL database.

I have many sources defined on the application itself, and not all can be checked on the same time basis because of restrictions (Twitter and its 350 queries per hour, for example), so the idea is to cron them separately by passing sources as arguments.

myscript.py --update --source ABC (Fetch, parse, check and save data from ABC source) myscript.py --update --source XYZ (Fetch, parse, check and save data from XYZ source)

So far this point, I got that working fine on my local cron, but I'd like to get this running on Google App Engine, with something like this:

cron.yaml:

cron:
- description: update source ABC
  url: /myscript.py --source ABC
  schedule: every 5 minutes
  login: admin
- description: update source XYZ
  url: /myscript.py --source XYZ
  schedule: every 12 minutes
  login: admin

I haven't found any way to get this done on App Engine Cron documentation. Any workarounds?

Answers


Put the source variable in your url path:

cron:
- description: update source ABC
  url: /cron/ABC/
  schedule: every 5 minutes
  login: admin
- description: update source XYZ
  url: /cron/XYZ/
  schedule: every 12 minutes
  login: admin

webapp.WSGIApplication([('/cron/([^/]+)/', CronHandler)])    

class CronHandler(webapp.RequestHandler):
    def post(self, source): 
            #do something with source variable...

Need Your Help

Windows Phone 8 HTML5 App and Themes

javascript html5 windows-phone-8

I’m working on a WP8 HTML5 Game and was trying to be responsive to the theme the user selected.

C# .NET - Garbled character when writing 56623 with StreamWriter

c# .net character-encoding char streamwriter

I have an issue with writing the character 56623 to a stream using a StreamWriter in UTF16 (the issue persists in other encodings as well). If I get the buffer from the stream, it contains the value