我的项目使用以下python库:
requests==2.18.4
requests-toolbelt==0.8.0
打电话到主.py在
^{pr2}$使用请求库时,App engine正在google云日志中记录错误消息:
AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/latest/reference/urllib3.contrib.html.
AppEnginePlatformWarning: URLFetch does not support granular timeout settings, reverting to total or default URLFetch timeout.
但这实际上只是警告,我的代码按预期工作。但是这个日志对我来说有问题,因为当我看到统计数据时,我不知道日志中是否真的有错误。这就是为什么我要把它记录为警告。在
这里有一个stackoverflow答案。这个答案说明,如果这个警告显示在GAE标准环境中,那么代码将正常工作。所以这对我来说真的是个警告。如何记录? AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets
您可以使用
logging.captureWarnings
函数来执行此操作。在从docs:
在
appengine_config.py
中执行logging.captureWarnings(True)
会导致这些警告被记录为对我的警告。在另请参阅warnings模块的文档。在
编辑:
This question包含此代码片段,用于完全抑制消息:
相关问题 更多 >
编程相关推荐