I want to call external urls using cron job of Google App Engine. And开发者_Python百科 I also want to induce sleep between cron jobs.
Is that possible?
You can't directly fetch external URLs using a cron job, but this is easy to work around: Just define a cron job that, as it sole activity, fetches an external URL using the urlfetch API.
Sleeping inside a request is possible as long as it doesn't exceed 30 seconds of execution time, but generally a very bad idea. Instead, use the task queue with a delay so the task will execute when you want it to.
If you sleep inside the job, you can run out of time just like a regular request (see docs):
A URL invoked by cron is subject to the same limits and quotas as a normal HTTP request, including the request time limit.
So you will probably want to use the scheduling to approximate a sleep call. So if you want to sleep for two minute, use:
every 2 minutes
精彩评论