Cron在本地主机上工作,但在部署Appengine时不工作 [英] Cron works on local host but not when deployed Appengine

查看:157
本文介绍了Cron在本地主机上工作,但在部署Appengine时不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Python工作在我的本地主机的cron工作,但当它部署到appengine,它不再工作。

I have a cron job in python that works on my localhost but when it is deployed to appengine, it no longer works.

  pl = db.Query(Venue).order("id")
    list = pl.fetch(limit=0)
    for p in pl:
        base_url = 'http://search.twitter.com/search.json?rpp=100&q=4sq.com/'
        query = p.twitter_ID
        url_string = base_url + query
        json_text = fetch(url_string)
        json_response = simplejson.loads(json_text.content) 
        result = json_response['results']
        for f in result:
            user = f['from_user'] 
            print user   


$ b b

这在本地工作正常,但在服务器上我得到以下错误:

This works fine locally but on the server I get the following error:


'results'Traceback $ b last):File
/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/init.py,
line 515,in 调用
handler.get(* groups)文件/base/data/home/apps/hoosheer/4.347697940058059704/hoosheer_main.py,
行199,在get
result = json_response ['results'] KeyError:'results'

'results' Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/init.py", line 515, in call handler.get(*groups) File "/base/data/home/apps/hoosheer/4.347697940058059704/hoosheer_main.py", line 199, in get result = json_response['results'] KeyError: 'results'

这样工作,直到我部署了第二个版本。有没有办法解决这个问题?

This did work until I deployed my second version. Is there any way I can fix this?

推荐答案

JSON 'results'字段,因为Twitter允许的每个Ip请求已达到最大限额的可用请求;这解释了为什么从你的国内IP你没有任何问题,你没有得到一个HTTP 420响应代码。

The JSON 'results' field is not returned because the requests per Ip that Twitter allows has reached the max quota of available requests; this explains why from your domestic IP you don't have any problem and you don't get an HTTP 420 response code.

不幸的是,Google App Engine使用共享的IP地址池 * 来发送urlfetch请求和 Twitter搜索API 不支持身份验证。

Unluckily Google App Engine uses a shared pool of IP addresses* for outgoing urlfetch requests and Twitter search APIs does not support authentication.


搜索API速率限制


search.twitter.com上托管的Search API不会将
计入REST API限制。但是,
来自IP地址
的所有请求将应用于搜索速率限制。
搜索速率限制不是
public以阻止不必要的
搜索使用和滥用,但是比REST速率限制高
。我们
觉得搜索速率限制是
自由的,并且对于大多数
应用程序是足够的,并且知道许多
应用程序供应商已经找到它b b b适合他们的需要。 p>

Requests to the Search API, hosted on search.twitter.com, do not count towards the REST API limit. However, all requests coming from an IP address are applied to a Search Rate Limit. The Search Rate Limit isn't made public to discourage unnecessary search usage and abuse, but it is higher than the REST Rate Limit. We feel the Search Rate Limit is both liberal and sufficient for most applications and know that many application vendors have found it suitable for their needs.

这会迫使您认真考虑Google App Engine是否是您应用程式的正确选择。

This would force you to seriously think if Google App Engine is a correct choice for your application.

*我有同样的问题这里,但幸运的是,API的开发人员启用了一个身份验证机制,允许来自同一个IP的身份验证请求。

*I had the same problem here but luckily the API's developer has enabled an authentication mechanism that allows authenticated requests from the same IP.

这篇关于Cron在本地主机上工作,但在部署Appengine时不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆