即使系统抛出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 Apps Marketplace请求 - 状态?
- 10. Google App Engine静态IP
- 11. Google App Engine。 Google应用引擎将POST请求视为GET
- 12. Google App Engine HTTP
- 13. Google App Engine - java.security.AccessControlException?
- 14. Google App Engine
- 15. Google App Engine APNS
- 16. App Engine + Google Documents
- 17. Google App Engine ASP.net
- 18. Google App Engine ThreadSafe
- 19. Google App Engine Memcache
- 20. Google App Engine Blob
- 21. Google App Engine Geohashing
- 22. Google App Engine DeobfuscatorBuilder
- 23. SSLHandshakeError - Google App Engine
- 24. Google App Engine - JDODetachedFieldAccessException
- 25. Google App Engine Profiler
- 26. Python - Google App Engine
- 27. App Engine HTTP状态代码消息
- 28. Google购物状态API HTTPS请求
- 29. Google App Engine加载请求非常频繁
- 30. Google App Engine的Blobstore适用于30秒请求超时?
你不能只是关闭重试? – Thilo 2011-01-13 07:13:47