即使系统抛出500,是否可以将http请求状态设置为200? 我有一个正在运行的任务。当GAE抛出http请求500时,我想在任务结束时手动将其设置为200,以防止重试任务。Google App Engine请求状态
1
A
回答
3
典型模式返回一个200状态码是包装try
和except
子句之间的代码:
try:
do your stuff
except:
logging.error("Something bad happened")
这个例子捕捉所有总是返回200 status code
例外,在你的应用程序,你可能希望添加一个适当的例外列表来捕捉;对于某些类型的瞬态异常,提出一个500错误是正确的,这个错误隐含地告诉App Engine再次尝试该任务。
编辑:
作为正确的建议,你应该使用的logging.exception
代替logging.error
包括日志中的堆栈跟踪。
try:
do your stuff
except:
logging.exception("Something bad happened") #It will log the stacktrace too
这有第二个好处,它可以让你启用ereporter服务后,通过电子邮件接收日志报告。
+1
使用logging.exception而不是logging.error,因此它将包含堆栈跟踪。 – 2011-01-13 23:26:14
相关问题
- 1. Google App Engine - 请求类query_string
- 2. Google App Engine:状态码403
- 3. 多次执行Google App Engine请求
- 4. Google App Engine请求成本估算
- 5. Google App Engine处理并行请求
- 6. 从Google App Engine发送请求
- 7. Google App Engine - http请求/响应
- 8. 无法控制Google App Engine上的静态文件请求
- 9. Google App Engine静态IP
- 10. Google App Engine
- 11. Google App Engine Memcache
- 12. Google App Engine DeobfuscatorBuilder
- 13. Google App Engine Profiler
- 14. Google App Engine ASP.net
- 15. Google App Engine ThreadSafe
- 16. Python - Google App Engine
- 17. App Engine + Google Documents
- 18. SSLHandshakeError - Google App Engine
- 19. App Engine HTTP状态代码消息
- 20. Google App Engine中的请求感知代码 - os.environ?
- 21. 无法部署到Google App Engine - 请求无效,原因不明
- 22. Google App Engine的Blobstore适用于30秒请求超时?
- 23. 所有版本的Google App Engine应用程序请求日志
- 24. 在Google App Engine(Python)的RequestHandler外部获取请求uri
- 25. Google App Engine加载请求非常频繁
- 26. Google App Engine - Blobstore请求正在制作中,不在开发中
- 27. 烧瓶 - 在Google App Engine中获取请求参数?
- 28. 可以在Google App Engine上使用Python请求库吗?
- 29. Google App Engine:我如何干这个基本的请求处理?
- 30. Google App Engine - 是否在请求之间重置os.environ?
你不能只是关闭重试? – Thilo 2011-01-13 07:13:47