App Engine: Is time.sleep() counting towards my quotas?

丶灬走出姿态 提交于 2019-11-30 12:53:50

You certainly don't want to be trying to sleep in a system that's designed completely from the ground up to finish requests in the absolute shortest time possible :D

What you could do instead, is create a task for each geocode, (check out the deferred library). You'd want to specify a queue for this task, then just set the rate limit on the queue to whatever you feel the maps geocoder might be comfortable with.

This way every geocode will run, and you'll never go faster than the rate limit you set, and you don't need to do any plumbing.

I am fairly certain that queue tasks also count towards your CPU usage in GAP. Regarding sleep(), i don't think there will be CPU "penalty" from that but I think it's a bad style.

Why sleep at all? In your task, do a single geocoding and simply post another invocation to yourself in the queue in 3secs. See the parameter countdown When invoking http://code.google.com/intl/el/appengine/docs/python/taskqueue/functions.html#add .

Your experiment proves that the time.sleep time counts against your quota. Have a look at the experimental Task Queue API. If your task isn't user initiated, you could also use Cron tasks, but I don't know if this will work well with so small intervals.

This Issue reports that the reporter has not been billed for cpu seconds incurred by time.sleep(), but that they show up on their appstats. It is very likely appstats uses cprofile as well. Sleep is important for people trying to make better asyncronous proxies which he could use for geocoding larger set of items.

http://code.google.com/p/googleappengine/issues/detail?id=3291

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!